Commit 0e78bab9 authored by Romain Loth's avatar Romain Loth

better complement selection in meso view

spec: Dans la vue meso, lors d'une selection, changer tous les noeuds d'état (de sélectionné à déselectionné et vice-versa)
parent 712819e2
...@@ -3,7 +3,12 @@ ...@@ -3,7 +3,12 @@
// this class will be instanciated once (and exposed as TW.instance.selNgn) // this class will be instanciated once (and exposed as TW.instance.selNgn)
function SelectionEngine() { function SelectionEngine() {
// creates the union of prevsels and currsels, if addvalue // creates the union of prevsels and currsels, if addvalue
// called for:
// clickNode selections
// circleArea selections
// searchInput selections
this.SelectorEngine = function( args ) { this.SelectorEngine = function( args ) {
// console.log("addvalue, prevsels, currsels", args) // console.log("addvalue, prevsels, currsels", args)
...@@ -18,49 +23,26 @@ function SelectionEngine() { ...@@ -18,49 +23,26 @@ function SelectionEngine() {
// currsels = bunch of nodes from a click in the map // currsels = bunch of nodes from a click in the map
if(args.addvalue) { if(args.addvalue) {
// FOR SIMPLE UNIQUE UNION // FOR SIMPLE UNIQUE UNION
targeted = args.currsels.concat(args.prevsels.filter(function (item) { if ( TW.SystemState().level) {
return args.currsels.indexOf(item) < 0; targeted = args.currsels.concat(args.prevsels.filter(function (item) {
})); return args.currsels.indexOf(item) < 0;
} else targeted = args.currsels; }));
}
// meso view: complementary select if disjoint, deselect if overlap
else {
targeted = args.currsels.filter(function (item) {
return args.prevsels.indexOf(item) < 0;
}).concat(args.prevsels.filter(function (item) {
return args.currsels.indexOf(item) < 0;
}));;
}
}
else {
targeted = args.currsels;
}
if(targeted.length==0) return []; if(targeted.length==0) return [];
// ------------ FOR SETWISE COMPLEMENT ---------------------->8---------
// if(args.prevsels.length>0) {
// if(JSON.stringify(args.prevsels)==JSON.stringify(targeted)) {
// // this is just effective for Add[ ] ...
// // If previous selection is equal to the current one, you've nothing :D
// cancelSelection(false);
// return [];
// }
// var inter = this.intersect_safe(args.prevsels,targeted)
// if(inter.length>0) {
// var blacklist = {} , whitelist = {};
// for(var k in inter) blacklist[inter[k]]=true;
// for(var k in args.prevsels){
// let nid = args.prevsels[k]
// if(!blacklist[nid]) {
// whitelist[nid] = true;
// }
// }
// for(var k in targeted){
// let nid = targeted[k]
// if(!blacklist[nid]) {
// whitelist[nid] = true;
// }
// }
// targeted = Object.keys(whitelist);
// } else {// inter = 0 ==> click in other portion of the graph (!= current selection)
// // Union!
// if(args.addvalue) {
// targeted = currsels.concat(args.prevsels.filter(function (item) {
// return currsels.indexOf(item) < 0;
// }));
// }
// }
// }
// ---------------------------------------------------------->8---------
return targeted; return targeted;
}; };
......
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