Commit 41135c18 authored by Romain Loth's avatar Romain Loth

new label resize logic + use render rather than refresh is faster and usually enough + small fixes

parent 3b1cda59
...@@ -289,7 +289,7 @@ function selectionUni(currentNode){ ...@@ -289,7 +289,7 @@ function selectionUni(currentNode){
highlightSelectedNodes(false); highlightSelectedNodes(false);
opossites = []; opossites = [];
selections = []; selections = [];
TW.partialGraph.refresh(); TW.partialGraph.render();
} }
if((typeof selections[currentNode.id])=="undefined"){ if((typeof selections[currentNode.id])=="undefined"){
...@@ -308,7 +308,7 @@ function selectionUni(currentNode){ ...@@ -308,7 +308,7 @@ function selectionUni(currentNode){
TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8); TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8);
TW.partialGraph.refresh(); TW.partialGraph.render();
} }
//JUST ADEME //JUST ADEME
...@@ -467,7 +467,7 @@ function circleTrackMouse(e) { ...@@ -467,7 +467,7 @@ function circleTrackMouse(e) {
// } else n.forceLabel=false; // } else n.forceLabel=false;
// } // }
// if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) { // if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) {
// TW.partialGraph.refresh({skipIndexation:true}) // TW.partialGraph.render()
// } // }
// } // }
...@@ -492,7 +492,7 @@ function circleGetAreaNodes(camX0, camY0) { ...@@ -492,7 +492,7 @@ function circleGetAreaNodes(camX0, camY0) {
cursor_ray cursor_ray
) )
console.log('slightlyLargerNodeset', slightlyLargerNodeset) // console.log('slightlyLargerNodeset', slightlyLargerNodeset)
var exactNodeset = [] var exactNodeset = []
...@@ -518,7 +518,7 @@ function circleGetAreaNodes(camX0, camY0) { ...@@ -518,7 +518,7 @@ function circleGetAreaNodes(camX0, camY0) {
} }
} }
if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) { if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) {
TW.partialGraph.refresh({skipIndexation:true}) TW.partialGraph.render()
} }
return exactNodeset return exactNodeset
...@@ -584,7 +584,7 @@ function flashNodesArray (nodesArray) { ...@@ -584,7 +584,7 @@ function flashNodesArray (nodesArray) {
} }
console.log("nodesArray encompassed by:", minX, minY,';', maxX, maxY) console.log("nodesArray encompassed by:", minX, minY,';', maxX, maxY)
TW.partialGraph.refresh() TW.partialGraph.render()
} }
// BASIC MODULARITY // BASIC MODULARITY
......
...@@ -204,7 +204,7 @@ SelectionEngine = function() { ...@@ -204,7 +204,7 @@ SelectionEngine = function() {
TW.lastQuery = string ; TW.lastQuery = string ;
$("input#searchinput").val(""); $("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" ); $("input#searchinput").autocomplete( "close" );
TW.partialGraph.refresh({ skipIndexation: true }); TW.partialGraph.render();
return targeted.length return targeted.length
} }
...@@ -364,7 +364,7 @@ SelectionEngine = function() { ...@@ -364,7 +364,7 @@ SelectionEngine = function() {
overNodes=true; overNodes=true;
TW.partialGraph.refresh({skipIndexation:true}); TW.partialGraph.render();
updateLeftPanel_fix( selections , oppos ); updateLeftPanel_fix( selections , oppos );
...@@ -509,7 +509,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -509,7 +509,7 @@ TinaWebJS = function ( sigmacanvas ) {
SelInst.MultipleSelection2({nodes:targeted}); SelInst.MultipleSelection2({nodes:targeted});
cursor_size = prev_cursor_size; cursor_size = prev_cursor_size;
} }
TW.partialGraph.refresh({skipIndexation: true}); TW.partialGraph.render();
$("input#searchinput").val(""); $("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" ); $("input#searchinput").autocomplete( "close" );
...@@ -551,7 +551,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -551,7 +551,7 @@ TinaWebJS = function ( sigmacanvas ) {
cancelSelection(false); cancelSelection(false);
SelInst.MultipleSelection2({nodes:targeted}); SelInst.MultipleSelection2({nodes:targeted});
} }
TW.partialGraph.refresh({skipIndexation: true}); TW.partialGraph.render();
$("input#searchinput").val(""); $("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" ); $("input#searchinput").autocomplete( "close" );
...@@ -569,6 +569,8 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -569,6 +569,8 @@ TinaWebJS = function ( sigmacanvas ) {
var SelInst = new SelectionEngine(); var SelInst = new SelectionEngine();
document.getElementById('edges-switch').checked = customSettings.drawEdges
$("#semLoader").hide(); $("#semLoader").hide();
$("#closeloader").click(); $("#closeloader").click();
...@@ -604,7 +606,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -604,7 +606,7 @@ TinaWebJS = function ( sigmacanvas ) {
console.log("") console.log("")
console.log(" ############ changeLEVEL click"); console.log(" ############ changeLEVEL click");
changeLevel(); // <- est-ce que ça fait quelquechose ? changeLevel();
// $("#tabs1").click() // $("#tabs1").click()
ChangeGraphAppearanceByAtt(true) // cf. extras_explorer ChangeGraphAppearanceByAtt(true) // cf. extras_explorer
console.log(" ############ / changeLEVEL click"); console.log(" ############ / changeLEVEL click");
...@@ -634,7 +636,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -634,7 +636,7 @@ TinaWebJS = function ( sigmacanvas ) {
}, { duration: 400, queue: false }); }, { duration: 400, queue: false });
setTimeout(function() { setTimeout(function() {
partialGraph.resize(); partialGraph.resize();
partialGraph.refresh(); partialGraph.render();
}, 400); }, 400);
} }
else { else {
...@@ -654,7 +656,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -654,7 +656,7 @@ TinaWebJS = function ( sigmacanvas ) {
},{ duration: 400, queue: false }); },{ duration: 400, queue: false });
setTimeout(function() { setTimeout(function() {
partialGraph.resize(); partialGraph.resize();
partialGraph.refresh(); partialGraph.render();
}, 400); }, 400);
} }
}); });
...@@ -678,7 +680,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -678,7 +680,7 @@ TinaWebJS = function ( sigmacanvas ) {
// button CENTER // button CENTER
$("#lensButton").click(function () { $("#lensButton").click(function () {
// new sigma.js // new sigma.js
partialGraph.camera.goTo({x:0, y:0, ratio:1}) partialGraph.camera.goTo({x:0, y:0, ratio:1.2})
}); });
...@@ -762,7 +764,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -762,7 +764,7 @@ TinaWebJS = function ( sigmacanvas ) {
// cancelSelection(false); // cancelSelection(false);
// SelInst.MultipleSelection2( {nodes:targeted} ) // SelInst.MultipleSelection2( {nodes:targeted} )
// } // }
// partialGraph.refresh({skipIndexation:true}); // partialGraph.render();
// trackMouse(e); // trackMouse(e);
// -------------------------------------------/fragment from v1.customized // -------------------------------------------/fragment from v1.customized
...@@ -849,7 +851,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -849,7 +851,7 @@ TinaWebJS = function ( sigmacanvas ) {
if(partialGraph.forceatlas2.active) { if(partialGraph.forceatlas2.active) {
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
partialGraph.refresh({ skipIndexation: true }); partialGraph.render();
return; return;
} else { } else {
partialGraph.startForceAtlas2(); partialGraph.startForceAtlas2();
...@@ -875,61 +877,52 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -875,61 +877,52 @@ TinaWebJS = function ( sigmacanvas ) {
//finished //finished
$("#slidercat0nodessize").freshslider({ $("#slidercat0nodessize").freshslider({
step:1, step:.25,
min:-20, min:0,
max:20, max:5,
value:0, value: TW.partialGraph.settings('labelSizeRatio'),
bgcolor:"#27c470", bgcolor:"#27c470",
onchange:function(value){ onchange:function(value){
setTimeout(function (){
// new sigma.js loop on nodes POSS optimize
nds = TW.partialGraph.graph.nodes()
console.log("init: slider resize")
for(j=0 ; j<TW.partialGraph.nNodes ; j++){
if (nds[j]
&& nds[j].type == TW.catSoc) {
var n = nds[j]
var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
n.size = (newval<1.0)?1:newval;
sizeMult[TW.catSoc] = parseFloat(value-1)*0.3;
}
}
partialGraph.refresh({skipIndexation:true})
},
100);
}
});
//finished var adaptedLabelThreshold = (5 - value) + 1
$("#slidercat1nodessize").freshslider({ // console.log("value", value, "thres", adaptedLabelThreshold)
step:1,
min:-20, TW.partialGraph.settings('labelSizeRatio', value)
max:20, TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
value:0, TW.partialGraph.render()
bgcolor:"#FFA500",
onchange:function(value){
setTimeout(function (){
// new sigma.js loop on nodes POSS optimize
nds = TW.partialGraph.graph.nodes()
console.log("init: slider resize")
for(j=0 ; j<TW.partialGraph.nNodes ; j++){
if (nds[j]
&& nds[j].type == TW.catSem) {
var n = nds[j]
var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
n.size = (newval<1.0)?1:newval;
sizeMult[TW.catSem] = parseFloat(value-1)*0.3;
}
}
partialGraph.refresh({skipIndexation:true})
},
100);
} }
}); });
// //finished
// $("#slidercat1nodessize").freshslider({
// step:1,
// min:-20,
// max:20,
// value:0,
// bgcolor:"#FFA500",
// onchange:function(value){
// setTimeout(function (){
// // new sigma.js loop on nodes POSS optimize
// nds = TW.partialGraph.graph.nodes()
// console.log("init: slider resize")
// for(j=0 ; j<TW.partialGraph.nNodes ; j++){
// if (nds[j]
// && nds[j].type == TW.catSem) {
// var n = nds[j]
// var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
// n.size = (newval<1.0)?1:newval;
// sizeMult[TW.catSem] = parseFloat(value-1)*0.3;
// }
// }
// partialGraph.render()
// },
// 100);
// }
// });
//Cursor Size slider //Cursor Size slider
// + reindexation when size is settled (=> updates the quadtree) // + reindexation when size is settled (=> updates the quadtree)
var reindexTimeout = null // var reindexTimeout = null
$("#unranged-value").freshslider({ $("#unranged-value").freshslider({
step: 1, step: 1,
min:cursor_size_min, min:cursor_size_min,
...@@ -938,22 +931,36 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -938,22 +931,36 @@ TinaWebJS = function ( sigmacanvas ) {
onchange:function(value){ onchange:function(value){
// console.log("en cursorsize: "+value); // console.log("en cursorsize: "+value);
cursor_size=value; cursor_size=value;
if(cursor_size==0) partialGraph.refresh({skipIndexation:true}); if(cursor_size==0) partialGraph.render();
// have reindex ready to go for when user stops moving slider // have reindex ready to go for when user stops moving slider
if (reindexTimeout) { // if (reindexTimeout) {
// (debounced) // // (debounced)
clearTimeout(reindexTimeout) // clearTimeout(reindexTimeout)
reindexTimeout = null // reindexTimeout = null
} // }
reindexTimeout = setTimeout(function() { // reindexTimeout = setTimeout(function() {
TW.partialGraph.refresh({skipIndexation: false}) // TW.partialGraph.render()
// ===== // // =====
console.log("graph quadtree reindexed for cursor") // console.log("graph quadtree reindexed for cursor")
}, 500) // }, 500)
} }
}); });
// costly entire refresh (~400ms) only after stopped resizing for 3s
// NB: rescale middleware already reacted and except for large win size changes it handles the resize fine
// (so this fragment is only to accomodate the large changes)
var winResizeTimeout = null
window.addEventListener('resize', function(){
if (winResizeTimeout) {
clearTimeout(winResizeTimeout)
}
winResizeTimeout = setTimeout(function() {
console.log('did refresh')
TW.partialGraph.refresh()
}, 3000)
}, true)
} // finish initListeners } // finish initListeners
}; };
...@@ -560,7 +560,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -560,7 +560,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
} }
} }
TW.partialGraph.refresh({skipIndexation: true}) TW.partialGraph.render()
// console.log("\t\tedgesfilter:") // console.log("\t\tedgesfilter:")
// console.log("\t\t[ Starting FA2 ]") // console.log("\t\t[ Starting FA2 ]")
...@@ -678,7 +678,7 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit ...@@ -678,7 +678,7 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
} }
pushFilterValue(sliderDivID,filtervalue) pushFilterValue(sliderDivID,filtervalue)
TW.partialGraph.refresh() TW.partialGraph.render()
// [ Starting FA2 ] // [ Starting FA2 ]
setTimeout(function() { setTimeout(function() {
......
...@@ -214,13 +214,13 @@ if(RES["OK"]) { ...@@ -214,13 +214,13 @@ if(RES["OK"]) {
drawEdges: true, drawEdges: true,
drawNodes: true, drawNodes: true,
drawLabels: true, drawLabels: true,
// nodesPowRatio: 1, // nodesPowRatio: .1,
labelSize: "proportional", labelSize: "proportional",
font: "Ubuntu Condensed", font: "Ubuntu Condensed",
// labelColor: "node", // labelColor: "node",
fontStyle: "bold", // fontStyle: "bold",
batchEdgesDrawing: false, batchEdgesDrawing: true,
singleHover: true,
autoResize: true, autoResize: true,
mouseEnabled: true, mouseEnabled: true,
touchEnabled: false touchEnabled: false
...@@ -272,8 +272,6 @@ if(RES["OK"]) { ...@@ -272,8 +272,6 @@ if(RES["OK"]) {
TW.partialGraph.nNodes = TW.partialGraph.graph.nodes().length TW.partialGraph.nNodes = TW.partialGraph.graph.nodes().length
TW.partialGraph.nEdges = TW.partialGraph.graph.edges().length TW.partialGraph.nEdges = TW.partialGraph.graph.edges().length
TW.partialGraph.states = [] TW.partialGraph.states = []
TW.partialGraph.states[0] = false; TW.partialGraph.states[0] = false;
TW.partialGraph.states[1] = TW.SystemStates; TW.partialGraph.states[1] = TW.SystemStates;
...@@ -368,33 +366,6 @@ if(RES["OK"]) { ...@@ -368,33 +366,6 @@ if(RES["OK"]) {
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight"); EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight");
} }
set_ClustersLegend ( "clust_default" ) set_ClustersLegend ( "clust_default" )
} else {
//finished
$("#slidercat1nodessize").freshslider({
step:1,
min:-20,
max:20,
value:0,
bgcolor:"#FFA500",
onchange:function(value){
setTimeout(function (){
// POSS: custom index by n.type
var nds = TW.partialGraph.graph.nodes()
for (var j in nds) {
var n = nds[j]
if(TW.Nodes[n.id].type==TW.catSem) {
var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
n.size = (newval<1.0)?1:newval;
sizeMult[TW.catSem] = parseFloat(value-1)*0.3;
}
}
TW.partialGraph.refresh({skipIndexation:true});
},
100);
}
});
} }
if(typestring=="1|1") { if(typestring=="1|1") {
...@@ -411,7 +382,7 @@ if(RES["OK"]) { ...@@ -411,7 +382,7 @@ if(RES["OK"]) {
// REFA new sigma.js // REFA new sigma.js
TW.partialGraph.camera.goTo({x:0, y:0, ratio:.8, angle: 0}) TW.partialGraph.camera.goTo({x:0, y:0, ratio:1.2, angle: 0})
// fa2enabled=true; TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8).draw(); // fa2enabled=true; TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8).draw();
// $.doTimeout(1,function(){ // $.doTimeout(1,function(){
......
...@@ -39,7 +39,7 @@ function cancelSelection (fromTagCloud) { ...@@ -39,7 +39,7 @@ function cancelSelection (fromTagCloud) {
//Nodes colors go back to normal //Nodes colors go back to normal
// new sigma.js redraw // new sigma.js redraw
TW.partialGraph.refresh({ skipIndexation: true }); TW.partialGraph.render();
if(fromTagCloud==false){ if(fromTagCloud==false){
...@@ -68,7 +68,7 @@ function cancelSelection (fromTagCloud) { ...@@ -68,7 +68,7 @@ function cancelSelection (fromTagCloud) {
LevelButtonDisable(true); LevelButtonDisable(true);
// new sigma.js redraw // new sigma.js redraw
TW.partialGraph.refresh({ skipIndexation: true }); TW.partialGraph.render();
} }
function highlightSelectedNodes(flag){ function highlightSelectedNodes(flag){
...@@ -174,7 +174,7 @@ function RefreshState(newNOW){ ...@@ -174,7 +174,7 @@ function RefreshState(newNOW){
$("#category-B").show(); $("#category-B").show();
} }
TW.partialGraph.refresh({skipIndexation: true}); TW.partialGraph.render();
} }
...@@ -212,7 +212,7 @@ function htmlfied_alternodes(elems) { ...@@ -212,7 +212,7 @@ function htmlfied_alternodes(elems) {
function manualForceLabel(nodeid,active) { function manualForceLabel(nodeid,active) {
// console.log("manual|"+nodeid+"|"+active) // console.log("manual|"+nodeid+"|"+active)
TW.partialGraph.graph.nodes(nodeid).active=active; TW.partialGraph.graph.nodes(nodeid).active=active;
TW.partialGraph.refresh({skipIndexation:true}); TW.partialGraph.render();
} }
function htmlfied_samenodes(elems) { function htmlfied_samenodes(elems) {
......
...@@ -206,7 +206,7 @@ SigmaUtils = function () { ...@@ -206,7 +206,7 @@ SigmaUtils = function () {
this.toggleEdges = function() { this.toggleEdges = function() {
var now_flag = TW.partialGraph.settings('drawEdges') var now_flag = TW.partialGraph.settings('drawEdges')
TW.partialGraph.settings('drawEdges', !now_flag) TW.partialGraph.settings('drawEdges', !now_flag)
TW.partialGraph.refresh({skipIndexation:true}) TW.partialGraph.render()
} }
...@@ -259,7 +259,7 @@ function showMeSomeLabels(N){ ...@@ -259,7 +259,7 @@ function showMeSomeLabels(N){
} }
} }
// new sigma.js // new sigma.js
TW.partialGraph.refresh({ skipIndexation: true }); TW.partialGraph.render();
/*======= Show some labels at the beginning =======*/ /*======= Show some labels at the beginning =======*/
} }
...@@ -480,7 +480,7 @@ function clustersBy(daclass) { ...@@ -480,7 +480,7 @@ function clustersBy(daclass) {
set_ClustersLegend ( null ) set_ClustersLegend ( null )
TW.partialGraph.refresh({skipIndexation: true}); TW.partialGraph.render();
} }
...@@ -584,7 +584,7 @@ function colorsRelByBins(daclass) { ...@@ -584,7 +584,7 @@ function colorsRelByBins(daclass) {
set_ClustersLegend ( null ) set_ClustersLegend ( null )
TW.partialGraph.refresh({skipIndexation: true}); TW.partialGraph.render();
} }
...@@ -643,7 +643,7 @@ function colorsBy(daclass) { ...@@ -643,7 +643,7 @@ function colorsBy(daclass) {
} }
// [ / Edge-colour by source-target nodes-colours combination ] // [ / Edge-colour by source-target nodes-colours combination ]
set_ClustersLegend ( daclass ) set_ClustersLegend ( daclass )
TW.partialGraph.refresh({skipIndexation: true}); TW.partialGraph.render();
} }
//just for fun //just for fun
......
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