Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
01491368
Commit
01491368
authored
Apr 12, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fa2 reinit method for changeLevel
parent
a108fb7a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
196 additions
and
124 deletions
+196
-124
settings_explorerjs.js
settings_explorerjs.js
+1
-1
enviroment.js
tinawebJS/enviroment.js
+149
-118
main.js
tinawebJS/main.js
+9
-5
methods.js
tinawebJS/methods.js
+37
-0
No files found.
settings_explorerjs.js
View file @
01491368
...
...
@@ -92,7 +92,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
* - "off": button doesn't exist, fa2 stopped forever
**/
var
fa2enabled
=
false
;
//"off";
var
stopcriteria
=
false
;
var
fa2milliseconds
=
10
000
;
// for initial auto-run if fa2enabled and any
var
fa2milliseconds
=
5
000
;
// for initial auto-run if fa2enabled and any
// subsequent auto-runs if graph modified
// deprecated ?
...
...
tinawebJS/enviroment.js
View file @
01491368
...
...
@@ -283,126 +283,157 @@ function changeType() {
// and SysSt.level is aka swMacro
function
changeLevel
()
{
var
present
=
TW
.
partialGraph
.
states
.
slice
(
-
1
)[
0
];
// Last
var
past
=
TW
.
partialGraph
.
states
.
slice
(
-
2
)[
0
]
// avant Last
var
lastpos
=
TW
.
partialGraph
.
states
.
length
-
1
;
var
avantlastpos
=
lastpos
-
1
;
var
level
=
present
.
level
;
var
sels
=
present
.
selections
;
//[144, 384, 543]//TW.partialGraph.states.selections;
var
catDict
=
present
.
categoriesDict
;
// type "grammar"
// used to distinguish types in TW.Relations
// types eg [true] <=> '1'
// [true, true] <=> '1|1'
var
type_t0
=
present
.
type
;
var
str_type_t0
=
type_t0
.
map
(
Number
).
join
(
"|"
)
// [X|Y]-change (NOT operation over the received state [X\Y] )
var
type_t1
=
[]
for
(
var
i
in
type_t0
)
type_t1
[
i
]
=
!
type_t0
[
i
]
var
str_type_t1
=
type_t1
.
map
(
Number
).
join
(
"|"
)
// removed typing 2nd part (binSumCats) not useful for changeLevel
TW
.
partialGraph
.
graph
.
clear
();
var
voisinage
=
{}
// Dictionaries of: selection+neighbors
var
nodes_2_colour
=
{}
var
edges_2_colour
=
{}
// POSS: factorize with same strategy in MultipleSelection2 beginning
for
(
var
i
in
sels
)
{
s
=
sels
[
i
];
neigh
=
TW
.
Relations
[
str_type_t0
][
s
]
if
(
neigh
)
{
for
(
var
j
in
neigh
)
{
t
=
neigh
[
j
]
nodes_2_colour
[
t
]
=
false
;
edges_2_colour
[
s
+
";"
+
t
]
=
true
;
edges_2_colour
[
t
+
";"
+
s
]
=
true
;
if
(
!
selections
[
t
]
)
voisinage
[
Number
(
t
)
]
=
true
;
}
}
}
for
(
var
i
in
sels
)
nodes_2_colour
[
sels
[
i
]]
=
true
;
var
futurelevel
=
[]
if
(
present
.
level
)
{
// [Change to Local] when level=Global(1)
for
(
var
i
in
nodes_2_colour
)
add1Elem
(
i
)
for
(
var
i
in
edges_2_colour
)
add1Elem
(
i
)
// Adding intra-neighbors edges O(voisinage²)
voisinage
=
Object
.
keys
(
voisinage
)
for
(
var
i
=
0
;
i
<
voisinage
.
length
;
i
++
)
{
for
(
var
j
=
1
;
j
<
voisinage
.
length
;
j
++
)
{
if
(
voisinage
[
i
]
!=
voisinage
[
j
]
)
{
// console.log( "\t" + voisinage[i] + " vs " + voisinage[j] )
add1Elem
(
voisinage
[
i
]
+
";"
+
voisinage
[
j
]
)
}
}
}
// show waiting cursor
theHtml
.
classList
.
add
(
'waiting'
);
// let the waiting cursor appear
setTimeout
(
function
()
{
var
present
=
TW
.
partialGraph
.
states
.
slice
(
-
1
)[
0
];
// Last
var
past
=
TW
.
partialGraph
.
states
.
slice
(
-
2
)[
0
]
// avant Last
var
lastpos
=
TW
.
partialGraph
.
states
.
length
-
1
;
var
avantlastpos
=
lastpos
-
1
;
var
level
=
present
.
level
;
var
sels
=
present
.
selections
;
//[144, 384, 543]//TW.partialGraph.states.selections;
var
catDict
=
present
.
categoriesDict
;
// type "grammar"
// used to distinguish types in TW.Relations
// types eg [true] <=> '1'
// [true, true] <=> '1|1'
var
type_t0
=
present
.
type
;
var
str_type_t0
=
type_t0
.
map
(
Number
).
join
(
"|"
)
// [X|Y]-change (NOT operation over the received state [X\Y] )
var
type_t1
=
[]
for
(
var
i
in
type_t0
)
type_t1
[
i
]
=
!
type_t0
[
i
]
var
str_type_t1
=
type_t1
.
map
(
Number
).
join
(
"|"
)
TW
.
partialGraph
.
graph
.
clear
();
var
voisinage
=
{}
// Dictionaries of: selection+neighbors
var
nodes_2_colour
=
{}
var
edges_2_colour
=
{}
// POSS: factorize with same strategy in MultipleSelection2 beginning
for
(
var
i
in
sels
)
{
s
=
sels
[
i
];
neigh
=
TW
.
Relations
[
str_type_t0
][
s
]
if
(
neigh
)
{
for
(
var
j
in
neigh
)
{
t
=
neigh
[
j
]
nodes_2_colour
[
t
]
=
false
;
edges_2_colour
[
s
+
";"
+
t
]
=
true
;
edges_2_colour
[
t
+
";"
+
s
]
=
true
;
if
(
!
selections
[
t
]
)
voisinage
[
Number
(
t
)
]
=
true
;
}
}
}
for
(
var
i
in
sels
)
nodes_2_colour
[
sels
[
i
]]
=
true
;
var
futurelevel
=
[]
if
(
present
.
level
)
{
// [Change to Local] when level=Global(1)
for
(
var
i
in
nodes_2_colour
)
add1Elem
(
i
)
for
(
var
i
in
edges_2_colour
)
add1Elem
(
i
)
// Adding intra-neighbors edges O(voisinage²)
voisinage
=
Object
.
keys
(
voisinage
)
for
(
var
i
=
0
;
i
<
voisinage
.
length
;
i
++
)
{
for
(
var
j
=
1
;
j
<
voisinage
.
length
;
j
++
)
{
if
(
voisinage
[
i
]
!=
voisinage
[
j
]
)
{
// console.log( "\t" + voisinage[i] + " vs " + voisinage[j] )
add1Elem
(
voisinage
[
i
]
+
";"
+
voisinage
[
j
]
)
}
futurelevel
=
false
;
}
else
{
// [Change to Global] when level=Local(0)
for
(
var
n
in
TW
.
Nodes
)
{
if
(
type_t0
[
catDict
[
TW
.
Nodes
[
n
].
type
]])
add1Elem
(
n
)
}
for
(
var
e
in
TW
.
Edges
)
{
if
(
TW
.
Edges
[
e
].
categ
==
str_type_t0
)
add1Elem
(
e
)
}
}
futurelevel
=
false
;
// Selection is unchanged, no need to call MultipleSelection2
}
else
{
// [Change to Global] when level=Local(0)
// var t0 = performance.now()
for
(
var
n
in
TW
.
Nodes
)
{
if
(
type_t0
[
catDict
[
TW
.
Nodes
[
n
].
type
]])
// we add 1 by 1
add1Elem
(
n
)
}
for
(
var
e
in
TW
.
Edges
)
{
if
(
TW
.
Edges
[
e
].
categ
==
str_type_t0
)
add1Elem
(
e
)
}
// var t1 = performance.now()
futurelevel
=
true
;
// console.log("returning to global took:", t1-t0)
// Nodes Selection now:
if
(
sels
.
length
>
0
)
{
var
SelInst
=
new
SelectionEngine
();
SelInst
.
MultipleSelection2
({
nodes
:
sels
,
nodesDict
:
nodes_2_colour
,
edgesDict
:
edges_2_colour
});
overNodes
=
true
;
}
}
// console.log("enviroment changeLevel nodes_2_colour", nodes_2_colour)
TW
.
partialGraph
.
states
[
avantlastpos
]
=
{};
TW
.
partialGraph
.
states
[
avantlastpos
].
level
=
present
.
level
;
TW
.
partialGraph
.
states
[
avantlastpos
].
selections
=
present
.
selections
;
TW
.
partialGraph
.
states
[
avantlastpos
].
type
=
present
.
type
;
TW
.
partialGraph
.
states
[
avantlastpos
].
opposites
=
present
.
opposites
;
TW
.
partialGraph
.
states
[
avantlastpos
].
categories
=
present
.
categories
;
//to_del
TW
.
partialGraph
.
states
[
avantlastpos
].
categoriesDict
=
present
.
categoriesDict
;
//to_del
TW
.
partialGraph
.
states
[
lastpos
].
setState
({
type
:
present
.
type
,
level
:
futurelevel
,
sels
:
Object
.
keys
(
selections
).
map
(
Number
),
oppos
:
[]
})
TW
.
partialGraph
.
states
[
lastpos
].
categories
=
present
.
categories
;
//to_del
TW
.
partialGraph
.
states
[
lastpos
].
categoriesDict
=
catDict
;
//to_del
TW
.
partialGraph
.
camera
.
goTo
({
x
:
0
,
y
:
0
,
ratio
:
1.2
,
angle
:
0
})
TW
.
partialGraph
.
refresh
()
// recreate FA2 nodes array after you change the nodes
reInitFa2
({
useSoftMethod
:
!
futurelevel
,
callback
:
function
()
{
theHtml
.
classList
.
remove
(
'waiting'
);
// when going local, it's nice to see the selected nodes rearrange
if
(
!
futurelevel
)
{
TW
.
partialGraph
.
startForceAtlas2
();
setTimeout
(
function
(){
TW
.
partialGraph
.
stopForceAtlas2
();
},
fa2milliseconds
)
}
}
futurelevel
=
true
;
}
// console.log("enviroment changeLevel nodes_2_colour", nodes_2_colour)
// Nodes Selection now:
if
(
sels
.
length
>
0
)
{
var
SelInst
=
new
SelectionEngine
();
SelInst
.
MultipleSelection2
({
nodesDict
:
nodes_2_colour
,
edgesDict
:
edges_2_colour
});
overNodes
=
true
;
}
TW
.
partialGraph
.
states
[
avantlastpos
]
=
{};
TW
.
partialGraph
.
states
[
avantlastpos
].
level
=
present
.
level
;
TW
.
partialGraph
.
states
[
avantlastpos
].
selections
=
present
.
selections
;
TW
.
partialGraph
.
states
[
avantlastpos
].
type
=
present
.
type
;
TW
.
partialGraph
.
states
[
avantlastpos
].
opposites
=
present
.
opposites
;
TW
.
partialGraph
.
states
[
avantlastpos
].
categories
=
present
.
categories
;
//to_del
TW
.
partialGraph
.
states
[
avantlastpos
].
categoriesDict
=
present
.
categoriesDict
;
//to_del
TW
.
partialGraph
.
states
[
lastpos
].
setState
({
type
:
present
.
type
,
level
:
futurelevel
,
sels
:
Object
.
keys
(
selections
).
map
(
Number
),
oppos
:
[]
})
TW
.
partialGraph
.
states
[
lastpos
].
categories
=
present
.
categories
;
//to_del
TW
.
partialGraph
.
states
[
lastpos
].
categoriesDict
=
catDict
;
//to_del
TW
.
partialGraph
.
camera
.
goTo
({
x
:
0
,
y
:
0
,
ratio
:
1.2
,
angle
:
0
})
TW
.
partialGraph
.
refresh
()
// TODO fix Fa2 in this context
})
},
500
// cursor waiting
)
}
//============================= </ NEW BUTTONS > =============================//
...
...
tinawebJS/main.js
View file @
01491368
...
...
@@ -309,6 +309,8 @@ if(RES["OK"]) {
TW
.
nNodes
=
TW
.
partialGraph
.
graph
.
nodes
().
length
TW
.
nEdges
=
TW
.
partialGraph
.
graph
.
edges
().
length
// POSS make it TW.states
TW
.
partialGraph
.
states
=
[]
TW
.
partialGraph
.
states
[
0
]
=
false
;
TW
.
partialGraph
.
states
[
1
]
=
TW
.
SystemStates
;
...
...
@@ -416,14 +418,13 @@ if(RES["OK"]) {
}
}).
index
();
// config for any future forceAtlas2 calls
TW
.
partialGraph
.
configForceAtlas2
({
TW
.
FA2Params
=
{
// adapting speed -------------
slowDown
:
1
,
startingIterations
:
5
,
iterationsPerRender
:
3
,
barnesHutOptimize
:
tru
e
,
barnesHutTheta
:
.
5
,
barnesHutOptimize
:
fals
e
,
//
barnesHutTheta: .5,
// global behavior -----------
linLogMode
:
true
,
...
...
@@ -438,7 +439,10 @@ if(RES["OK"]) {
// (but rather not needed when data already shows topic-centered
// node groups and/nor when preferential attachment type of data)
outboundAttractionDistribution
:
false
})
}
// init FA2 for any future forceAtlas2 calls
TW
.
partialGraph
.
configForceAtlas2
(
TW
.
FA2Params
)
// REFA new sigma.js
TW
.
partialGraph
.
camera
.
goTo
({
x
:
0
,
y
:
0
,
ratio
:
1.2
,
angle
:
0
})
...
...
tinawebJS/methods.js
View file @
01491368
...
...
@@ -808,3 +808,40 @@ function saveGraphIMG(){
var
strData
=
edgesDiv
.
toDataURL
(
"image/png"
);
document
.
location
.
href
=
strData
.
replace
(
"image/png"
,
strDownloadMime
)
}
// reInitFa2 : to call after changeType/changeLevel
// ------------------------------------------------
// sigma 1.2 FA2 supervisor is lazily inited at the
// first call (startForceAtlas2 or configForceAtlas2)
// but it keeps its own node index (as byteArray) and
// so needs to be recreated when nodes change
function
reInitFa2
(
params
)
{
if
(
!
params
)
params
=
{}
if
(
params
.
useSoftMethod
)
{
// soft method: we just update FA2 internal index
// (is good enough if new nodes are subset of previous nodes)
TW
.
partialGraph
.
supervisor
.
graphToByteArrays
()
// now cb
if
(
params
.
callback
)
{
params
.
callback
()
}
}
else
{
TW
.
partialGraph
.
killForceAtlas2
()
// after 1s to let killForceAtlas2 finish
setTimeout
(
function
()
{
// init FA2
TW
.
partialGraph
.
configForceAtlas2
(
TW
.
FA2Params
)
// now cb
if
(
params
.
callback
)
{
params
.
callback
()
}
},
1000
)
}
}
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