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){
highlightSelectedNodes(false);
opossites = [];
selections = [];
TW.partialGraph.refresh();
TW.partialGraph.render();
}
if((typeof selections[currentNode.id])=="undefined"){
......@@ -308,7 +308,7 @@ function selectionUni(currentNode){
TW.partialGraph.zoomTo(TW.partialGraph._core.width / 2, TW.partialGraph._core.height / 2, 0.8);
TW.partialGraph.refresh();
TW.partialGraph.render();
}
//JUST ADEME
......@@ -467,7 +467,7 @@ function circleTrackMouse(e) {
// } else n.forceLabel=false;
// }
// 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) {
cursor_ray
)
console.log('slightlyLargerNodeset', slightlyLargerNodeset)
// console.log('slightlyLargerNodeset', slightlyLargerNodeset)
var exactNodeset = []
......@@ -518,7 +518,7 @@ function circleGetAreaNodes(camX0, camY0) {
}
}
if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) {
TW.partialGraph.refresh({skipIndexation:true})
TW.partialGraph.render()
}
return exactNodeset
......@@ -584,7 +584,7 @@ function flashNodesArray (nodesArray) {
}
console.log("nodesArray encompassed by:", minX, minY,';', maxX, maxY)
TW.partialGraph.refresh()
TW.partialGraph.render()
}
// BASIC MODULARITY
......
......@@ -204,7 +204,7 @@ SelectionEngine = function() {
TW.lastQuery = string ;
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
TW.partialGraph.refresh({ skipIndexation: true });
TW.partialGraph.render();
return targeted.length
}
......@@ -364,7 +364,7 @@ SelectionEngine = function() {
overNodes=true;
TW.partialGraph.refresh({skipIndexation:true});
TW.partialGraph.render();
updateLeftPanel_fix( selections , oppos );
......@@ -509,7 +509,7 @@ TinaWebJS = function ( sigmacanvas ) {
SelInst.MultipleSelection2({nodes:targeted});
cursor_size = prev_cursor_size;
}
TW.partialGraph.refresh({skipIndexation: true});
TW.partialGraph.render();
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
......@@ -551,7 +551,7 @@ TinaWebJS = function ( sigmacanvas ) {
cancelSelection(false);
SelInst.MultipleSelection2({nodes:targeted});
}
TW.partialGraph.refresh({skipIndexation: true});
TW.partialGraph.render();
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
......@@ -569,6 +569,8 @@ TinaWebJS = function ( sigmacanvas ) {
var SelInst = new SelectionEngine();
document.getElementById('edges-switch').checked = customSettings.drawEdges
$("#semLoader").hide();
$("#closeloader").click();
......@@ -604,7 +606,7 @@ TinaWebJS = function ( sigmacanvas ) {
console.log("")
console.log(" ############ changeLEVEL click");
changeLevel(); // <- est-ce que ça fait quelquechose ?
changeLevel();
// $("#tabs1").click()
ChangeGraphAppearanceByAtt(true) // cf. extras_explorer
console.log(" ############ / changeLEVEL click");
......@@ -634,7 +636,7 @@ TinaWebJS = function ( sigmacanvas ) {
}, { duration: 400, queue: false });
setTimeout(function() {
partialGraph.resize();
partialGraph.refresh();
partialGraph.render();
}, 400);
}
else {
......@@ -654,7 +656,7 @@ TinaWebJS = function ( sigmacanvas ) {
},{ duration: 400, queue: false });
setTimeout(function() {
partialGraph.resize();
partialGraph.refresh();
partialGraph.render();
}, 400);
}
});
......@@ -678,7 +680,7 @@ TinaWebJS = function ( sigmacanvas ) {
// button CENTER
$("#lensButton").click(function () {
// 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 ) {
// cancelSelection(false);
// SelInst.MultipleSelection2( {nodes:targeted} )
// }
// partialGraph.refresh({skipIndexation:true});
// partialGraph.render();
// trackMouse(e);
// -------------------------------------------/fragment from v1.customized
......@@ -849,7 +851,7 @@ TinaWebJS = function ( sigmacanvas ) {
if(partialGraph.forceatlas2.active) {
partialGraph.stopForceAtlas2();
partialGraph.refresh({ skipIndexation: true });
partialGraph.render();
return;
} else {
partialGraph.startForceAtlas2();
......@@ -875,61 +877,52 @@ TinaWebJS = function ( sigmacanvas ) {
//finished
$("#slidercat0nodessize").freshslider({
step:1,
min:-20,
max:20,
value:0,
step:.25,
min:0,
max:5,
value: TW.partialGraph.settings('labelSizeRatio'),
bgcolor:"#27c470",
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
$("#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.refresh({skipIndexation:true})
},
100);
var adaptedLabelThreshold = (5 - value) + 1
// console.log("value", value, "thres", adaptedLabelThreshold)
TW.partialGraph.settings('labelSizeRatio', value)
TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
TW.partialGraph.render()
}
});
// //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
// + reindexation when size is settled (=> updates the quadtree)
var reindexTimeout = null
// var reindexTimeout = null
$("#unranged-value").freshslider({
step: 1,
min:cursor_size_min,
......@@ -938,22 +931,36 @@ TinaWebJS = function ( sigmacanvas ) {
onchange:function(value){
// console.log("en cursorsize: "+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
if (reindexTimeout) {
// (debounced)
clearTimeout(reindexTimeout)
reindexTimeout = null
}
reindexTimeout = setTimeout(function() {
TW.partialGraph.refresh({skipIndexation: false})
// =====
console.log("graph quadtree reindexed for cursor")
}, 500)
// if (reindexTimeout) {
// // (debounced)
// clearTimeout(reindexTimeout)
// reindexTimeout = null
// }
// reindexTimeout = setTimeout(function() {
// TW.partialGraph.render()
// // =====
// console.log("graph quadtree reindexed for cursor")
// }, 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
};
......@@ -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\t[ Starting FA2 ]")
......@@ -678,7 +678,7 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
}
pushFilterValue(sliderDivID,filtervalue)
TW.partialGraph.refresh()
TW.partialGraph.render()
// [ Starting FA2 ]
setTimeout(function() {
......
......@@ -214,13 +214,13 @@ if(RES["OK"]) {
drawEdges: true,
drawNodes: true,
drawLabels: true,
// nodesPowRatio: 1,
// nodesPowRatio: .1,
labelSize: "proportional",
font: "Ubuntu Condensed",
// labelColor: "node",
fontStyle: "bold",
batchEdgesDrawing: false,
// fontStyle: "bold",
batchEdgesDrawing: true,
singleHover: true,
autoResize: true,
mouseEnabled: true,
touchEnabled: false
......@@ -272,8 +272,6 @@ if(RES["OK"]) {
TW.partialGraph.nNodes = TW.partialGraph.graph.nodes().length
TW.partialGraph.nEdges = TW.partialGraph.graph.edges().length
TW.partialGraph.states = []
TW.partialGraph.states[0] = false;
TW.partialGraph.states[1] = TW.SystemStates;
......@@ -368,33 +366,6 @@ if(RES["OK"]) {
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight");
}
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") {
......@@ -411,7 +382,7 @@ if(RES["OK"]) {
// 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();
// $.doTimeout(1,function(){
......
......@@ -39,7 +39,7 @@ function cancelSelection (fromTagCloud) {
//Nodes colors go back to normal
// new sigma.js redraw
TW.partialGraph.refresh({ skipIndexation: true });
TW.partialGraph.render();
if(fromTagCloud==false){
......@@ -68,7 +68,7 @@ function cancelSelection (fromTagCloud) {
LevelButtonDisable(true);
// new sigma.js redraw
TW.partialGraph.refresh({ skipIndexation: true });
TW.partialGraph.render();
}
function highlightSelectedNodes(flag){
......@@ -174,7 +174,7 @@ function RefreshState(newNOW){
$("#category-B").show();
}
TW.partialGraph.refresh({skipIndexation: true});
TW.partialGraph.render();
}
......@@ -212,7 +212,7 @@ function htmlfied_alternodes(elems) {
function manualForceLabel(nodeid,active) {
// console.log("manual|"+nodeid+"|"+active)
TW.partialGraph.graph.nodes(nodeid).active=active;
TW.partialGraph.refresh({skipIndexation:true});
TW.partialGraph.render();
}
function htmlfied_samenodes(elems) {
......
......@@ -206,7 +206,7 @@ SigmaUtils = function () {
this.toggleEdges = function() {
var now_flag = TW.partialGraph.settings('drawEdges')
TW.partialGraph.settings('drawEdges', !now_flag)
TW.partialGraph.refresh({skipIndexation:true})
TW.partialGraph.render()
}
......@@ -259,7 +259,7 @@ function showMeSomeLabels(N){
}
}
// new sigma.js
TW.partialGraph.refresh({ skipIndexation: true });
TW.partialGraph.render();
/*======= Show some labels at the beginning =======*/
}
......@@ -480,7 +480,7 @@ function clustersBy(daclass) {
set_ClustersLegend ( null )
TW.partialGraph.refresh({skipIndexation: true});
TW.partialGraph.render();
}
......@@ -584,7 +584,7 @@ function colorsRelByBins(daclass) {
set_ClustersLegend ( null )
TW.partialGraph.refresh({skipIndexation: true});
TW.partialGraph.render();
}
......@@ -643,7 +643,7 @@ function colorsBy(daclass) {
}
// [ / Edge-colour by source-target nodes-colours combination ]
set_ClustersLegend ( daclass )
TW.partialGraph.refresh({skipIndexation: true});
TW.partialGraph.render();
}
//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