Commit 8e111c66 authored by Romain Loth's avatar Romain Loth

fix deselections (actually commit 21064f3b went too far)

we need both neighbor agregated sums AND detailed info
parent f22f6272
......@@ -179,26 +179,29 @@ function SelectionEngine() {
// Dictionaries of: selection+neighbors for the new state and updateRelatedNodesPanel
let selections = {}
// detailed relations sorted by types and srcid (for state cache, deselects etc)
let activeRelations = {}
activeRelations[activetypesKey] = {}
// cumulated neighbor weights no matter what srcid (for tagCloud etc)
let sameSideNeighbors = {}
let oppoSideNeighbors = {}
// targeted arg 'nodes' can be nid array or single nid
var ndsids=[]
if(args.nodes) {
if(! $.isArray(args.nodes)) ndsids.push(args.nodes);
else ndsids=args.nodes;
// for state cache
activeRelations[activetypesKey] = {}
// shortcut
var sameSideNeighbors = activeRelations[activetypesKey]
for(var i in ndsids) {
var srcnid = ndsids[i];
if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][srcnid] ) {
var neighs = TW.Relations[activetypesKey][srcnid]
activeRelations[activetypesKey][srcnid] = {}
if(neighs) {
for(var j in neighs) {
var tgtnid = neighs[j]
......@@ -223,14 +226,21 @@ function SelectionEngine() {
sameSideNeighbors[tgtnid]=0
}
// and the detailed info
if (typeof activeRelations[activetypesKey][srcnid][tgtnid] == 'undefined') {
activeRelations[activetypesKey][srcnid][tgtnid]=0
}
// **make the edge active**
if (e1 && !e1.hidden) {
e1.customAttrs.activeEdge = 1;
sameSideNeighbors[tgtnid] += e1.weight || 1
activeRelations[activetypesKey][srcnid][tgtnid] += e1.weight || 1
}
if (e2 && !e2.hidden) {
e2.customAttrs.activeEdge = 1;
sameSideNeighbors[tgtnid] += e2.weight || 1
activeRelations[activetypesKey][srcnid][tgtnid] += e2.weight || 1
}
// we add as neighbor to color it (except if already in targeted)
......@@ -263,12 +273,21 @@ function SelectionEngine() {
let srcnid = theSelection[i]
var bipaNeighs = TW.Relations["1|1"][srcnid];
activeRelations["1|1"][srcnid] = {}
for(var k in bipaNeighs) {
if (typeof activeRelations["1|1"][bipaNeighs[k]] == "undefined")
activeRelations["1|1"][bipaNeighs[k]] = 0;
if (typeof activeRelations["1|1"][srcnid][bipaNeighs[k]] == "undefined") {
activeRelations["1|1"][srcnid][bipaNeighs[k]] = 0;
}
if (typeof oppoSideNeighbors[bipaNeighs[k]] == "undefined") {
oppoSideNeighbors[bipaNeighs[k]] = 0 ;
}
// cumulated for all srcnids
activeRelations["1|1"][bipaNeighs[k]]++;
oppoSideNeighbors[bipaNeighs[k]]++
// and the details
activeRelations["1|1"][srcnid][bipaNeighs[k]]++;
}
}
}
......@@ -279,12 +298,12 @@ function SelectionEngine() {
let same = []
if (activeRelations["1|1"]) {
oppos = ArraySortByValue(activeRelations["1|1"], function(a,b){
oppos = ArraySortByValue(oppoSideNeighbors, function(a,b){
return b-a
});
}
same = ArraySortByValue(activeRelations[activetypesKey], function(a,b){
same = ArraySortByValue(sameSideNeighbors, function(a,b){
return b-a
});
......@@ -311,6 +330,7 @@ function SelectionEngine() {
TW.partialGraph.render();
updateRelatedNodesPanel( theSelection , same, oppos )
if (TW.conf.debug.logSelections) {
......
......@@ -427,6 +427,8 @@ function changeLevel() {
var sels = present.selectionNids ;//[144, 384, 543]//TW.states[last].selectionNids;
deselectNodes()
let selsChecker = {}
for (let i in sels) {
selsChecker[sels[i]] = true
......@@ -448,7 +450,6 @@ function changeLevel() {
var nodes_2_colour = {}
var edges_2_colour = {}
// £TODO: factorize with same strategy in MultipleSelection2 beginning
for(var i in sels) {
s = sels[i];
neigh = TW.Relations[activetypesKey][s]
......@@ -463,9 +464,6 @@ function changeLevel() {
}
}
}
for(var i in sels)
nodes_2_colour[sels[i]]=true;
var futurelevel = null
......
......@@ -1015,7 +1015,6 @@ function dictfyJSON( data , categories ) {
for(var nid in data.nodes) {
let n = data.nodes[nid];
console.log(">>", n)
let node = {}
node.id = (n.id) ? n.id : nid ; // use the key if no id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment