Commit 5be215b5 authored by Romain Loth's avatar Romain Loth

Merge commit 'de07de2' (faster sliders) into with_tina_1.2

parents 86562d73 d5ebd7ae
...@@ -751,7 +751,6 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -751,7 +751,6 @@ var TinaWebJS = function ( sigmacanvas ) {
this.style.cursor = 'wait' this.style.cursor = 'wait'
// and waiting icon // and waiting icon
this.insertBefore(createWaitIcon('noverlapwait'), this.children[0]) this.insertBefore(createWaitIcon('noverlapwait'), this.children[0])
var listener = TW.partialGraph.startNoverlap(); var listener = TW.partialGraph.startNoverlap();
var noverButton = this var noverButton = this
listener.bind('stop', function(event) { listener.bind('stop', function(event) {
...@@ -1080,8 +1079,7 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -1080,8 +1079,7 @@ var TinaWebJS = function ( sigmacanvas ) {
// for context: family/type prop value, // for context: family/type prop value,
// for values: the property to filter // for values: the property to filter
NodeWeightFilter ( `#slidercat${activeId}nodesweight` , NodeWeightFilter ( `#slidercat${activeId}nodesweight` ,
TW.categories[activeId] , TW.categories[activeId]
"size"
); );
// ex: #slidercat1edgesweight // ex: #slidercat1edgesweight
......
...@@ -599,28 +599,29 @@ function changeLevel() { ...@@ -599,28 +599,29 @@ function changeLevel() {
//=========================== < FILTERS-SLIDERS > ===========================// //=========================== < FILTERS-SLIDERS > ===========================//
// census of edges by type and by size // census of edges by property criterion (eg 'weight'), for a given type
// (replaces deprecated AlgorithmForSliders, but without the sqrt transform) // (replaces deprecated AlgorithmForSliders, but without the sqrt transform)
function edgeSizesLookup() { function edgeSizesLookup(eTypeStrs, criterion) {
var edgeweis = {} var edgeweis = {}
for (let i in TW.edgeIds) { for (let i in TW.edgeIds) {
let e = TW.partialGraph.graph.edges(TW.edgeIds[i]) let e = TW.partialGraph.graph.edges(TW.edgeIds[i])
if (e) {
for (var etype_i in eTypeStrs) {
let eTypeStr = eTypeStrs[etype_i]
if (e && e.categ && e.categ == eTypeStr) {
if (!edgeweis[e.categ]) edgeweis[e.categ] = {} if (!edgeweis[e.categ]) edgeweis[e.categ] = {}
if (!edgeweis[e.categ][e.weight]) edgeweis[e.categ][e.weight] = [] if (!edgeweis[e.categ][e[criterion]]) edgeweis[e.categ][e[criterion]] = []
edgeweis[e.categ][e.weight].push(e.id) edgeweis[e.categ][e[criterion]].push(e.id)
}
} }
} }
return edgeweis return edgeweis
} }
function edgeSizesSteps(eTypeStr) { function edgeSizesSteps(eTypeStr, esizesCensus) {
let esizesCensus = edgeSizesLookup()
var stepToIdsArray = [] var stepToIdsArray = []
if (esizesCensus[eTypeStr]) { if (esizesCensus[eTypeStr]) {
var sortedSizes = Object.keys( var sortedSizes = Object.keys(
esizesCensus[eTypeStr] esizesCensus[eTypeStr]
...@@ -631,7 +632,7 @@ function edgeSizesSteps(eTypeStr) { ...@@ -631,7 +632,7 @@ function edgeSizesSteps(eTypeStr) {
} }
} }
// console.warn ("edgeSizesSteps:", eTypeStr, stepToIdsArray) // console.warn (`edgeSizesSteps: for etype ${eTypeStr}` , stepToIdsArray)
return stepToIdsArray return stepToIdsArray
} }
...@@ -653,8 +654,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -653,8 +654,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
return; return;
} }
// building the index // building the index with the generic indexing function
var stepToIdsArr = edgeSizesSteps(typestr) var esizesCensus = edgeSizesLookup([typestr], criteria)
// sorting it for the type we need
var stepToIdsArr = edgeSizesSteps(typestr, esizesCensus)
var steps = stepToIdsArr.length var steps = stepToIdsArr.length
if(steps<2) { if(steps<2) {
...@@ -725,10 +729,6 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -725,10 +729,6 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
var filtervalue = low+"-"+high var filtervalue = low+"-"+high
var lastvalue = TW.gui.lastFilters[`${sliderDivID}/${typestr}`] var lastvalue = TW.gui.lastFilters[`${sliderDivID}/${typestr}`]
// sliderDivID+"_"+filtervalue
console.debug("\nprevious value "+lastvalue+" | current value "+filtervalue)
if(filtervalue!=lastvalue) { if(filtervalue!=lastvalue) {
// [ Stopping FA2 ] // [ Stopping FA2 ]
...@@ -746,11 +746,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -746,11 +746,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
if(mint0!=mint1) { if(mint0!=mint1) {
if(mint0<mint1) { if(mint0<mint1) {
delflag = true; delflag = true;
console.log("cotainferior --||>--------|| a la derecha") // console.log("cotainferior --||>--------|| a la derecha")
} }
if(mint0>mint1) { if(mint0>mint1) {
addflag = true; addflag = true;
console.log("cotainferior --<||--------|| a la izquierda") // console.log("cotainferior --<||--------|| a la izquierda")
} }
iterarr = calc_range(mint0,mint1).sort(compareNumbers); iterarr = calc_range(mint0,mint1).sort(compareNumbers);
} }
...@@ -758,11 +758,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -758,11 +758,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
if(maxt0!=maxt1) { if(maxt0!=maxt1) {
if(maxt0<maxt1) { if(maxt0<maxt1) {
addflag = true; addflag = true;
console.log("cotasuperior ||--------||>-- a la derecha") // console.log("cotasuperior ||--------||>-- a la derecha")
} }
if(maxt0>maxt1) { if(maxt0>maxt1) {
delflag = true; delflag = true;
console.log("cotasuperior ||--------<||-- a la izquierda") // console.log("cotasuperior ||--------<||-- a la izquierda")
} }
iterarr = calc_range(maxt0,maxt1).sort(compareNumbers); iterarr = calc_range(maxt0,maxt1).sort(compareNumbers);
} }
...@@ -786,23 +786,14 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -786,23 +786,14 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
else else
console.warn("skipped missing eid", eid) console.warn("skipped missing eid", eid)
// global level case
if(present.level) {
console.log("\tADD "+eid)
// n = eid.split(";")
// if(n.length>1)
// console.log("\t\tsource:("+TW.Nodes[n[0]].x+","+TW.Nodes[n[0]].y+") ||| target:("+TW.Nodes[n[1]].x+","+TW.Nodes[n[1]].y+")")
add1Elem(eid)
}
// local level case // local level case
// stepToIdsArr is full of edges that don't really exist at this point // stepToIdsArr is full of edges that don't really exist at this point
else { // we need to distinguish between absent edges => keep them absent because of local
// and edges with hidden nodes => effect of a node slider => make them appear
if (! present.level) {
// NB we assume the sigma convention eid = "nid1;nid2" // NB we assume the sigma convention eid = "nid1;nid2"
let nidkeys = eid.split(';') let nidkeys = eid.split(';')
console.log(nidkeys)
if (nidkeys.length != 2) { if (nidkeys.length != 2) {
console.error("invalid edge id:" + eid) console.error("invalid edge id:" + eid)
...@@ -816,31 +807,39 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -816,31 +807,39 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
&& TW.partialGraph.graph.nodes(tid)) { && TW.partialGraph.graph.nodes(tid)) {
if(TW.partialGraph.graph.nodes(sid).hidden) unHide(sid) if(TW.partialGraph.graph.nodes(sid).hidden) unHide(sid)
if(TW.partialGraph.graph.nodes(tid).hidden) unHide(tid) if(TW.partialGraph.graph.nodes(tid).hidden) unHide(tid)
if (! TW.partialGraph.graph.edges(eid)) {
add1Elem(eid) add1Elem(eid)
} }
TW.partialGraph.graph.edges(eid).hidden = false
TW.Edges[eid].lock = false;
} }
} }
}
// in any case we show the edge
// global level case
if (! TW.partialGraph.graph.edges(eid)) {
// legacy fallback shouldn't be necessary
add1Elem(eid)
}
TW.partialGraph.graph.edges(eid).hidden = false
TW.Edges[eid].lock = false;
} }
} }
} else { } else {
if(delflag) { if(delflag) {
console.log("deleting "+eids.join())
for(var i in eids) { for(var i in eids) {
ID = eids[i] let eid = eids[i]
if(!isUndef(TW.partialGraph.graph.edges(ID))) { if(!isUndef(TW.partialGraph.graph.edges(eid))) {
var t0 = performance.now() var t0 = performance.now()
TW.partialGraph.graph.dropEdge(ID) if (TW.partialGraph.graph.edges(eid)) {
TW.partialGraph.graph.edges(eid).hidden = true
TW.Edges[eid].lock = true;
}
var t1 = performance.now() var t1 = performance.now()
TW.Edges[ID].lock = true;
// usually very long b/c sigma has to update indexes
// <=> shift same arrays many times
totalDeletingTime += (t1-t0) totalDeletingTime += (t1-t0)
// POSS ideally: use .hidden
console.log("\tDEL "+ID) // console.log("\thiding "+eid)
// n = ID.split(";") // n = ID.split(";")
// if(n.length>1) // if(n.length>1)
...@@ -851,11 +850,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -851,11 +850,11 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
} }
} }
if (delflag) if(delflag) {
console.info('totalDeletingTime', totalDeletingTime) console.info('totalDeletingTime', totalDeletingTime)
// NB: performance with hiding: more or less 8x faster than with dropEdge on large graphs
}
// console.log("\t\tedgesfilter:")
// console.log("\t\t[ Starting FA2 ]")
// [ Starting FA2 ] // [ Starting FA2 ]
setTimeout(function() { setTimeout(function() {
sigma_utils.smartForceAtlas({'duration': 2000}) // shorter FA2 sufficient sigma_utils.smartForceAtlas({'duration': 2000}) // shorter FA2 sufficient
...@@ -866,31 +865,26 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) { ...@@ -866,31 +865,26 @@ function EdgeWeightFilter(sliderDivID , typestr , criteria) {
TW.gui.lastFilters[`${sliderDivID}/${typestr}`] = filtervalue TW.gui.lastFilters[`${sliderDivID}/${typestr}`] = filtervalue
} }
else {
// console.log('edges:::same position')
}
// in any case // in any case
setTimeout( function() { setTimeout( function() {
TW.partialGraph.refresh() TW.partialGraph.refresh()
TW.gui.elHtml.classList.remove('waiting') TW.gui.elHtml.classList.remove('waiting')
}, 20) }, 40)
}, 1500) // large-ish debounce timeout }, 1000) // large-ish debounce timeout
}, 40) // wait cursor timeout }, 40) // wait cursor timeout
} }
}); });
} }
// Execution modes: // Execution modes:
// NodeWeightFilter ( "#sliderANodeWeight" , "Document" , "size") // NodeWeightFilter ( "#sliderANodeWeight" , "Document")
// NodeWeightFilter ( "#sliderBNodeWeight" , "NGram" , "size") // NodeWeightFilter ( "#sliderBNodeWeight" , "NGram")
function NodeWeightFilter( sliderDivID , tgtNodeType , criteria) { function NodeWeightFilter( sliderDivID , tgtNodeType) {
if (typeof tgtNodeType == "undefined") { if (typeof tgtNodeType == "undefined") {
throw 'no nodetype' throw 'no nodetype'
......
...@@ -52,7 +52,7 @@ TW.pushState = function( args ) { ...@@ -52,7 +52,7 @@ TW.pushState = function( args ) {
$(".for-nodecategory-0").show() $(".for-nodecategory-0").show()
$(".for-nodecategory-1").hide(); $(".for-nodecategory-1").hide();
NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size"); NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0]);
EdgeWeightFilter("#slidercat0edgesweight", typesKey, "weight"); EdgeWeightFilter("#slidercat0edgesweight", typesKey, "weight");
} }
...@@ -61,7 +61,7 @@ TW.pushState = function( args ) { ...@@ -61,7 +61,7 @@ TW.pushState = function( args ) {
$(".for-nodecategory-0").hide() $(".for-nodecategory-0").hide()
$(".for-nodecategory-1").show(); $(".for-nodecategory-1").show();
NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size"); NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1]);
EdgeWeightFilter("#slidercat1edgesweight", typesKey, "weight"); EdgeWeightFilter("#slidercat1edgesweight", typesKey, "weight");
} }
...@@ -69,10 +69,11 @@ TW.pushState = function( args ) { ...@@ -69,10 +69,11 @@ TW.pushState = function( args ) {
if(typesKey=="1|1") { if(typesKey=="1|1") {
$(".for-nodecategory-0").show() $(".for-nodecategory-0").show()
$(".for-nodecategory-1").show(); $(".for-nodecategory-1").show();
NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size"); NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0]);
NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size"); NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1]);
// only truly bipartite edges => only one GUI slider // only truly bipartite edges => only one GUI slider
showDisabledSlider("#slidercat0edgesweight")
EdgeWeightFilter("#slidercat1edgesweight", "1|1", "weight"); EdgeWeightFilter("#slidercat1edgesweight", "1|1", "weight");
} }
} }
......
...@@ -570,7 +570,9 @@ var SigmaUtils = function () { ...@@ -570,7 +570,9 @@ var SigmaUtils = function () {
this.toggleEdges(false) this.toggleEdges(false)
} }
try {
TW.partialGraph.startForceAtlas2(); TW.partialGraph.startForceAtlas2();
} catch(e) {return}
var icon = createWaitIcon('layoutwait') var icon = createWaitIcon('layoutwait')
var btn = document.querySelector('#layoutButton') var btn = document.querySelector('#layoutButton')
......
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