Commit 4096b7d3 authored by Romain Loth's avatar Romain Loth

fine-tune visual settings

make noverlap account for new node sizes slider ; adjust legends after changetype ; etc
parent de6b4496
...@@ -145,9 +145,9 @@ TW.conf = (function(TW){ ...@@ -145,9 +145,9 @@ TW.conf = (function(TW){
TWConf.maxDiscreteValues = 15 TWConf.maxDiscreteValues = 15
TWConf.legendsBins = 7 TWConf.legendsBins = 7
// to normalize node sizes: (NB not very useful because tina normalizes them at display) // to normalize node sizes (larger range does increase visual size difference)
TWConf.desirableNodeSizeMin=1; TWConf.desirableNodeSizeMin=1;
TWConf.desirableNodeSizeMax=2; TWConf.desirableNodeSizeMax=10;
// ============= // =============
...@@ -256,8 +256,8 @@ TW.conf = (function(TW){ ...@@ -256,8 +256,8 @@ TW.conf = (function(TW){
font: "Droid Sans", // font params font: "Droid Sans", // font params
fontStyle: "bold", fontStyle: "bold",
defaultLabelColor: '#000', // labels text color defaultLabelColor: '#000', // labels text color
labelSizeRatio: 1, // initial label size (on the slider) labelSizeRatio: 1, // label size in ratio of node size
labelThreshold: 5, // min node cam size to start showing label labelThreshold: 4, // min node cam size to start showing label
// (old tina: showLabelsIfZoom) // (old tina: showLabelsIfZoom)
// hovered nodes // hovered nodes
...@@ -301,8 +301,8 @@ TW.conf = (function(TW){ ...@@ -301,8 +301,8 @@ TW.conf = (function(TW){
// relative sizes (iff ChangeType == both nodetypes) // relative sizes (iff ChangeType == both nodetypes)
TWConf.sizeMult = []; TWConf.sizeMult = [];
TWConf.sizeMult[0] = 1.0; // ie for node type 0 (<=> sem) TWConf.sizeMult[0] = 1.0; // ie for node type 0 (<=> sem)
TWConf.sizeMult[1] = 5.0; // ie for node type 1 (<=> soc) TWConf.sizeMult[1] = 10.0; // ie for node type 1 (<=> soc)
// =========== // ===========
......
...@@ -756,6 +756,12 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -756,6 +756,12 @@ 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])
// reconfigure to account for nodesizes (if current sizes up => margin needs up)
let sizeFactor = Math.max.apply(null, TW.gui.sizeRatios)
TW.gui.noverlapConf.nodeMargin = .5 * sizeFactor
TW.gui.noverlapConf.scaleNodes = 1.5 * sizeFactor
TW.partialGraph.configNoverlap(TW.gui.noverlapConf)
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) {
...@@ -1112,13 +1118,8 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -1112,13 +1118,8 @@ var TinaWebJS = function ( sigmacanvas ) {
labelSizeTimeout = setTimeout(function(){ labelSizeTimeout = setTimeout(function(){
if (TW.gui.sizeRatios[0] != value) { if (TW.gui.sizeRatios[0] != value) {
TW.gui.sizeRatios[0] = value TW.gui.sizeRatios[0] = value
// ------------------------------------------------------------- // also adapt label threshold
// generic efficient method acting on entire graphs label ratio TW.partialGraph.settings('labelThreshold', getSizeFactor())
// (can't use it b/c we need to distinguish by type)
// var adaptedLabelThreshold = 7 - value
// TW.partialGraph.settings('labelSizeRatio', value)
// TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
// -------------------------------------------------------------
TW.partialGraph.render() TW.partialGraph.render()
} }
}, 200) }, 200)
...@@ -1138,6 +1139,8 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -1138,6 +1139,8 @@ var TinaWebJS = function ( sigmacanvas ) {
labelSizeTimeout = setTimeout(function(){ labelSizeTimeout = setTimeout(function(){
if (TW.gui.sizeRatios[1] != value) { if (TW.gui.sizeRatios[1] != value) {
TW.gui.sizeRatios[1] = value TW.gui.sizeRatios[1] = value
// also adapt label threshold
TW.partialGraph.settings('labelThreshold', getSizeFactor())
TW.partialGraph.render() TW.partialGraph.render()
} }
}, 200) }, 200)
...@@ -1212,5 +1215,4 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -1212,5 +1215,4 @@ var TinaWebJS = function ( sigmacanvas ) {
return activereltypes; return activereltypes;
} }
}; };
...@@ -27,6 +27,17 @@ TW.gui.lastFilters = {} ...@@ -27,6 +27,17 @@ TW.gui.lastFilters = {}
TW.gui.sizeRatios = [1,1] // sizeRatios per nodetype TW.gui.sizeRatios = [1,1] // sizeRatios per nodetype
TW.gui.noverlapConf = {
nodeMargin: .4,
scaleNodes: 1.5,
gridSize: 300,
speed: 7,
maxIterations: 8,
easing: 'quadraticOut', // animation transition function
duration: 1500 // animation duration
// NB animation happens *after* processing
}
// POSS: themed variants (ex: for dark bg vs light bg) // POSS: themed variants (ex: for dark bg vs light bg)
// contrasted color list for clusterColoring() // contrasted color list for clusterColoring()
...@@ -475,9 +486,13 @@ function changeType(optionaltypeFlag) { ...@@ -475,9 +486,13 @@ function changeType(optionaltypeFlag) {
console.log("selection transitive projection from",sourceNids, "to", newselsArr) console.log("selection transitive projection from",sourceNids, "to", newselsArr)
} }
// update the color menu // update the gui (POSS could be handled by TW.pushGUIState)
TW.gui.handpickedcolor = false TW.gui.handpickedcolor = false
changeGraphAppearanceByFacets( getActivetypesNames() ) changeGraphAppearanceByFacets( getActivetypesNames() )
if (typeFlag != 'all') {
graphResetLabelsAndSizes()
}
TW.partialGraph.settings('labelThreshold', getSizeFactor())
// recreates FA2 nodes array from new nodes // recreates FA2 nodes array from new nodes
reInitFa2({ reInitFa2({
......
...@@ -531,18 +531,7 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -531,18 +531,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
// init FA2 for any future forceAtlas2 calls // init FA2 for any future forceAtlas2 calls
TW.partialGraph.configForceAtlas2(TW.FA2Params) TW.partialGraph.configForceAtlas2(TW.FA2Params)
// NB: noverlap conf depends on sizeRatios so updated before each run
// init noverlap for any future calls
TW.partialGraph.configNoverlap({
nodeMargin: .4,
scaleNodes: 1.5,
gridSize: 400,
speed: 5,
maxIterations: 10,
easing: 'quadraticOut', // animation transition function
duration: 1500 // animation duration
// NB animation happens *after* processing
});
// REFA new sigma.js // REFA new sigma.js
TW.partialGraph.camera.goTo({x:0, y:0, ratio:0.9, angle: 0}) TW.partialGraph.camera.goTo({x:0, y:0, ratio:0.9, angle: 0})
......
...@@ -175,6 +175,11 @@ function getActiverelsKey(someState) { ...@@ -175,6 +175,11 @@ function getActiverelsKey(someState) {
} }
} }
// how many types are currently active
function getNActive(someState) {
return TW.SystemState().activetypes.filter(function(bool){return bool}).length
}
// transitional function: // transitional function:
// ---------------------- // ----------------------
// Goal: determine if a single nodetype or global activetype is semantic or social // Goal: determine if a single nodetype or global activetype is semantic or social
......
...@@ -565,6 +565,13 @@ var SigmaUtils = function () { ...@@ -565,6 +565,13 @@ var SigmaUtils = function () {
else { else {
if ((TW.conf.fa2Enabled || args.manual) if ((TW.conf.fa2Enabled || args.manual)
&& TW.partialGraph.graph.nNodes() >= TW.conf.minNodesForAutoFA2) { && TW.partialGraph.graph.nNodes() >= TW.conf.minNodesForAutoFA2) {
setTimeout(function(){
// NB in here scope: 'this' is the window
if (TW.partialGraph.isForceAtlas2Running())
sigma_utils.ourStopFA2()
},
args.duration)
// hide edges during work for smaller cpu load // hide edges during work for smaller cpu load
if (TW.partialGraph.settings('drawEdges')) { if (TW.partialGraph.settings('drawEdges')) {
this.toggleEdges(false) this.toggleEdges(false)
...@@ -578,13 +585,6 @@ var SigmaUtils = function () { ...@@ -578,13 +585,6 @@ var SigmaUtils = function () {
var btn = document.querySelector('#layoutButton') var btn = document.querySelector('#layoutButton')
btn.insertBefore(icon, btn.children[0]) btn.insertBefore(icon, btn.children[0])
setTimeout(function(){
// NB in here scope: 'this' is the window
if (TW.partialGraph.isForceAtlas2Running())
sigma_utils.ourStopFA2()
},
args.duration)
return; return;
} }
...@@ -1029,6 +1029,23 @@ function clusterColoring(daclass) { ...@@ -1029,6 +1029,23 @@ function clusterColoring(daclass) {
} }
// for labelThreshold:
// factor to reduce speed of growth of the amount of labels when size goes up
// /!\ important params to avoid having unreadable mess of labels or none at all
function getSizeFactor(val) {
let nActive = getNActive()
let sliderFactor
let adjustmentFactor = TW.conf.sigmaJsDrawingProperties.labelThreshold
if (nActive == 1) {
let activeId = TW.catDict[getActivetypesNames()[0]]
sliderFactor = TW.gui.sizeRatios[activeId]
}
else {
sliderFactor = Math.min.apply(null, TW.gui.sizeRatios)
}
return adjustmentFactor * (sliderFactor * 1.15)
}
// mobile versions should get lighter settings // mobile versions should get lighter settings
function mobileAdaptConf() { function mobileAdaptConf() {
......
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