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

WIP mini optimize render 1/2

start integrating neighbors in systemstate (objective: avoid loops on full graph when deselecting with greyEverything) + removed grey flag which was now always == (!active && !highlight)
parent 24baa5d2
...@@ -172,7 +172,7 @@ TW.conf = (function(TW){ ...@@ -172,7 +172,7 @@ TW.conf = (function(TW){
TWConf.clusterColorsAtt = true; // show "Set colors" menu TWConf.clusterColorsAtt = true; // show "Set colors" menu
TWConf.dragNodesAvailable = true; // allow dragging nodes with CTRL+click TWConf.dragNodesAvailable = false; // allow dragging nodes with CTRL+click
TWConf.deselectOnclickStage = true // click on background remove selection ? TWConf.deselectOnclickStage = true // click on background remove selection ?
// (except when dragging) // (except when dragging)
...@@ -300,7 +300,7 @@ TW.conf = (function(TW){ ...@@ -300,7 +300,7 @@ TW.conf = (function(TW){
logFacets: false, // ...about parsing node attribute:value facets logFacets: false, // ...about parsing node attribute:value facets
logSettings: false, // ...about settings at Tina and Sigma init time logSettings: false, // ...about settings at Tina and Sigma init time
logStates: false, // ...about TW.states array logStates: false, // ...about TW.states array
logSelections: false logSelections: true
} }
......
...@@ -154,8 +154,6 @@ function SelectionEngine() { ...@@ -154,8 +154,6 @@ function SelectionEngine() {
if (!args) args = {} if (!args) args = {}
if (isUndef(args.nodes)) args.nodes = [] if (isUndef(args.nodes)) args.nodes = []
if (isUndef(args.nodesDict)) args.nodesDict = {}
if (isUndef(args.edgesDict)) args.edgesDict = {}
if (TW.conf.debug.logSelections) { if (TW.conf.debug.logSelections) {
var tMS2_deb = performance.now() var tMS2_deb = performance.now()
...@@ -164,6 +162,8 @@ function SelectionEngine() { ...@@ -164,6 +162,8 @@ function SelectionEngine() {
console.log("nodes", args.nodes) console.log("nodes", args.nodes)
} }
console.warn('££TODO we could grey only active and neighbors if we kept neighbors')
greyEverything(); greyEverything();
var sameSideNeighbors = {} var sameSideNeighbors = {}
...@@ -179,17 +179,11 @@ function SelectionEngine() { ...@@ -179,17 +179,11 @@ function SelectionEngine() {
var activetypesKey = getActivetypesKey() var activetypesKey = getActivetypesKey()
// console.log ("console.loging the Type:")
// console.log (activetypesKey)
// console.log (" - - - - - - ")
// Dictionaries of: selection+neighbors
var nodes_2_colour = args.nodesDict
var edges_2_colour = args.edgesDict
// Dictionaries of: selection+neighbors
let selections = {} let selections = {}
// targeted arg 'nodes' can be nid array or single nid // targeted arg 'nodes' can be nid array or single nid
var ndsids=[] var ndsids=[]
if(args.nodes) { if(args.nodes) {
...@@ -197,79 +191,57 @@ function SelectionEngine() { ...@@ -197,79 +191,57 @@ function SelectionEngine() {
else ndsids=args.nodes; else ndsids=args.nodes;
for(var i in ndsids) { for(var i in ndsids) {
var s = ndsids[i]; var srcnid = ndsids[i];
if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][s] ) { if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][srcnid] ) {
var neigh = TW.Relations[activetypesKey][s] var neighs = TW.Relations[activetypesKey][srcnid]
if(neigh) { if(neighs) {
for(var j in neigh) { for(var j in neighs) {
var t = neigh[j] var tgtnid = neighs[j]
let tgt = TW.partialGraph.graph.nodes(tgtnid)
// highlight edges (except if n hidden or e dropped (<=> lock)) // highlight edges (except if n hidden or e dropped (<=> lock))
// POSS: use sigma's own index to avoid checking if node exists or edge dropped // POSS: use sigma's own index to avoid checking if edge dropped
if (TW.partialGraph.graph.nodes(t) if (tgt && !tgt.hidden) {
&& ! TW.partialGraph.graph.nodes(t).hidden
&& (
(TW.Edges[s+";"+t] && !TW.Edges[s+";"+t].lock)
||
(TW.Edges[t+";"+s] && !TW.Edges[t+";"+s].lock)
)
) {
edges_2_colour[s+";"+t]=true;
edges_2_colour[t+";"+s]=true;
// we add as neighbor to color it (except if already in targeted) let eid1 = srcnid+';'+tgtnid
if (!nodes_2_colour[t]) nodes_2_colour[t]=false; let eid2 = tgtnid+';'+srcnid
// since we're there we keep the neighbors info if ( (TW.Edges[eid1] && !TW.Edges[eid1].lock)
if (typeof sameSideNeighbors[t] == 'undefined') { ||
sameSideNeighbors[t]=0 (TW.Edges[eid2] && !TW.Edges[eid2].lock) ) {
}
if (TW.Edges[s+";"+t]) let e1 = TW.partialGraph.graph.edges(eid1)
sameSideNeighbors[t] += TW.Edges[s+";"+t].weight || 1 let e2 = TW.partialGraph.graph.edges(eid2)
if (TW.Edges[t+";"+s]) // since we're there we'll also keep the neighbors info
sameSideNeighbors[t] += TW.Edges[t+";"+s].weight || 1 if (typeof sameSideNeighbors[tgtnid] == 'undefined') {
} sameSideNeighbors[tgtnid]=0
}
} }
}
// we make the selected (source) node active too
nodes_2_colour[s]=true;
// update local selections dict // **make the edge active**
selections[ndsids[i]]=1; if (e1 && !e1.hidden) {
e1.customAttrs.activeEdge = 1;
sameSideNeighbors[tgtnid] += e1.weight || 1
} }
if (e2 && !e2.hidden) {
e2.customAttrs.activeEdge = 1;
sameSideNeighbors[tgtnid] += e2.weight || 1
} }
// separate loop to allow nodes_2_colour without nodes as args (only used in changeType) // we add as neighbor to color it (except if already in targeted)
for(var nid in nodes_2_colour) { if (!tgt.customAttrs.active) tgt.customAttrs.highlight = 1;
if(nid) {
n = TW.partialGraph.graph.nodes(nid)
if(n) {
// our deselected flag
n.customAttrs['grey'] = 0;
// it's a selected node
if(nodes_2_colour[nid]) {
n.active = true;
} }
// it's a neighbor
else {
n.customAttrs.highlight = true;
} }
} }
} }
} }
// we make the selected (source) node active too
let src = TW.partialGraph.graph.nodes(srcnid)
src.customAttrs.active = true;
for(var eid in edges_2_colour) { // update local selections dict
selections[ndsids[i]]=1;
// at this point all edges are grey b/c greyEverything() was called
let an_edge = TW.partialGraph.graph.edges(eid)
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.customAttrs['grey'] = 0;
an_edge.customAttrs['activeEdge'] = 1;
} }
} }
...@@ -278,29 +250,17 @@ function SelectionEngine() { ...@@ -278,29 +250,17 @@ function SelectionEngine() {
let theSelection = Object.keys(selections) let theSelection = Object.keys(selections)
// it's a new SystemState
TW.pushState( { sels: theSelection } )
// we send our "gotNodeSet" event
// (signal for plugins that a search-selection was done or a new hand picked selection)
$('#searchinput').trigger({
type: "tw:gotNodeSet",
q: $("#searchinput").val(),
nodeIds: theSelection
});
// console.log("Event [gotNodeSet] sent from Tinaweb MultipleSelection2")
// neighbors of the opposite type // neighbors of the opposite type
if(TW.Relations["1|1"]) { if(TW.Relations["1|1"]) {
for(var s in theSelection) { for(var srcnid in theSelection) {
var bipaNeighs = TW.Relations["1|1"][theSelection[s]]; var bipaNeighs = TW.Relations["1|1"][theSelection[srcnid]];
for(var n in bipaNeighs) { for(var k in bipaNeighs) {
if (typeof oppositeSideNeighbors[bipaNeighs[n]] == "undefined") if (typeof oppositeSideNeighbors[bipaNeighs[k]] == "undefined")
oppositeSideNeighbors[bipaNeighs[n]] = 0; oppositeSideNeighbors[bipaNeighs[k]] = 0;
// £TODO weighted increment // £TODO weighted increment
oppositeSideNeighbors[bipaNeighs[n]]++; oppositeSideNeighbors[bipaNeighs[k]]++;
} }
} }
} }
...@@ -315,11 +275,22 @@ function SelectionEngine() { ...@@ -315,11 +275,22 @@ function SelectionEngine() {
}); });
if (TW.conf.debug.logSelections) { if (TW.conf.debug.logSelections) {
console.debug('new states\'s selectionNids', theSelection) console.log('new states\'s selectionNids', theSelection)
console.debug('oppos', oppos) console.log('oppos', oppos)
console.debug('same', same) console.log('same', same)
} }
// it's a new SystemState
TW.pushState( { 'sels': theSelection, 'same': same, 'oppos': oppos } )
// we send our "gotNodeSet" event
// (signal for plugins that a search-selection was done or a new hand picked selection)
$('#searchinput').trigger({
type: "tw:gotNodeSet",
q: $("#searchinput").val(),
nodeIds: theSelection
});
// global flag // global flag
TW.gui.selectionActive = true TW.gui.selectionActive = true
...@@ -466,13 +437,14 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -466,13 +437,14 @@ var TinaWebJS = function ( sigmacanvas ) {
// custom labels rendering // custom labels rendering
// - based on the normal one sigma.canvas.labels.def // - based on the normal one sigma.canvas.labels.def
// - additionnaly supports 'active/forcelabel' node property (magnify x 3) // - additionnaly supports 'active/highlight' node property (magnify x 3)
// - also handles 'forceLabel' property
sigmaModule.canvas.labels.def = tempo.twRender.canvas.labels.largeractive sigmaModule.canvas.labels.def = tempo.twRender.canvas.labels.largeractive
// custom hovers rendering // custom hovers rendering
// - based on the normal one sigma.canvas.hovers.def // - based on the normal one sigma.canvas.hovers.def
// - additionnaly magnifies all labels x 2 // - additionnaly magnifies all labels x 2
// - additionnaly supports 'active/forcelabel' node property (magnify x 3) // - additionnaly supports 'active/highlight' node property (magnify x 3)
sigmaModule.canvas.hovers.def = tempo.twRender.canvas.hovers.largerall sigmaModule.canvas.hovers.def = tempo.twRender.canvas.hovers.largerall
if (TW.conf.debug.logSettings) console.log('tw renderers registered in sigma module') if (TW.conf.debug.logSettings) console.log('tw renderers registered in sigma module')
...@@ -576,6 +548,8 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -576,6 +548,8 @@ var TinaWebJS = function ( sigmacanvas ) {
console.log(" ############ changeTYPE click"); console.log(" ############ changeTYPE click");
if (TW.partialGraph.isForceAtlas2Running()) if (TW.partialGraph.isForceAtlas2Running())
sigma_utils.ourStopFA2(); sigma_utils.ourStopFA2();
console.log("DBG before changeType SystemState:", TW.SystemState())
changeType(); changeType();
setTimeout(function(){ setTimeout(function(){
...@@ -851,11 +825,6 @@ var TinaWebJS = function ( sigmacanvas ) { ...@@ -851,11 +825,6 @@ var TinaWebJS = function ( sigmacanvas ) {
currsels:[theNodeId], currsels:[theNodeId],
prevsels: TW.SystemState().selectionNids prevsels: TW.SystemState().selectionNids
} ) } )
//
// not needed because selInst calls greyEverything
// cancelSelection(false, {norender:true}); // no need to render before MS2
// 2) // 2)
if(targeted.length>0) { if(targeted.length>0) {
selInst.MultipleSelection2( {nodes:targeted} ) selInst.MultipleSelection2( {nodes:targeted} )
......
...@@ -374,7 +374,7 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -374,7 +374,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
TW.nodeIds = Object.keys(dicts.nodes) // useful for loops TW.nodeIds = Object.keys(dicts.nodes) // useful for loops
TW.edgeIds = Object.keys(dicts.edges) TW.edgeIds = Object.keys(dicts.edges)
// in-place: pre-compute all color/grey/size properties // in-place: pre-compute all color/unselected color/size properties
prepareNodesRenderingProperties(TW.Nodes) prepareNodesRenderingProperties(TW.Nodes)
prepareEdgesRenderingProperties(TW.Edges, TW.Nodes) prepareEdgesRenderingProperties(TW.Edges, TW.Nodes)
......
...@@ -23,7 +23,10 @@ TW.pushState = function( args ) { ...@@ -23,7 +23,10 @@ TW.pushState = function( args ) {
if (!isUndef(args.activetypes)) newState.activetypes = args.activetypes if (!isUndef(args.activetypes)) newState.activetypes = args.activetypes
if (!isUndef(args.level)) newState.level = args.level; if (!isUndef(args.level)) newState.level = args.level;
// POSS1: add neighbors (of both types) in a .neighborsNids[type] slot // neighbors (of both types) in a .neighborsNids[type] slot
if(!isUndef(args.same)) newState.samesideSortdNeighs = args.same;
if(!isUndef(args.oppos)) newState.opposideSortdNeighs = args.oppos;
// POSS2: add filterSliders params to be able to recreate subsets at a given time // POSS2: add filterSliders params to be able to recreate subsets at a given time
// useful shortcut // useful shortcut
...@@ -124,7 +127,7 @@ function cancelSelection (fromTagCloud, settings) { ...@@ -124,7 +127,7 @@ function cancelSelection (fromTagCloud, settings) {
// clear the current state's selection and neighbors arrays // clear the current state's selection and neighbors arrays
// new state // new state
TW.pushState({sels:[]}) TW.pushState({sels:[], oppos:[], same:[]})
// global flag // global flag
TW.gui.selectionActive = false TW.gui.selectionActive = false
...@@ -137,7 +140,6 @@ function cancelSelection (fromTagCloud, settings) { ...@@ -137,7 +140,6 @@ function cancelSelection (fromTagCloud, settings) {
// console.log("cancelSelection: edge", e) // console.log("cancelSelection: edge", e)
if (e) { if (e) {
e.color = e.customAttrs['true_color']; e.color = e.customAttrs['true_color'];
e.customAttrs.grey = 0;
if (e.customAttrs.activeEdge) { if (e.customAttrs.activeEdge) {
e.customAttrs.activeEdge = 0; e.customAttrs.activeEdge = 0;
...@@ -147,17 +149,16 @@ function cancelSelection (fromTagCloud, settings) { ...@@ -147,17 +149,16 @@ function cancelSelection (fromTagCloud, settings) {
} }
//Nodes colors go back to previous //Nodes colors go back to previous
// £TODO partly duplicate effort with (de)highlightSelectedNodes and greyEverything // ££TODO partly duplicate effort with (de)highlightSelectedNodes and greyEverything
// => could be replaced by a (de)highlightSelectedAndNeighbors // => could be replaced by a (de)highlightSelectedAndNeighbors
// on smaller set (here entire nodeset!) // on smaller set (here entire nodeset!)
for(let j in TW.nodeIds){ for(let j in TW.nodeIds){
let n = TW.partialGraph.graph.nodes(TW.nodeIds[j]) let n = TW.partialGraph.graph.nodes(TW.nodeIds[j])
// console.log("cancelSelection: node", n) // console.log("cancelSelection: node", n)
if (n) { if (n) {
n.active = false; n.customAttrs.active = 0
n.customAttrs.grey = 0
n.customAttrs.forceLabel = 0
n.customAttrs.highlight = 0 n.customAttrs.highlight = 0
n.customAttrs.forceLabel = 0
// some colorings cases also modify size and label // some colorings cases also modify size and label
if (settings.resetLabels) { if (settings.resetLabels) {
...@@ -246,19 +247,14 @@ function highlightSelectedNodes(flag){ ...@@ -246,19 +247,14 @@ function highlightSelectedNodes(flag){
console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" sel:"+sels) console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" sel:"+sels)
for(let i in sels) { for(let i in sels) {
let nid = sels[i] let nid = sels[i]
TW.partialGraph.graph.nodes(nid).active = flag TW.partialGraph.graph.nodes(nid).customAttrs.active = flag
} }
} }
function manualForceLabel(nodeid, active, justHover) { function manualForceLabel(nodeid, active, justHover) {
// console.log("manual|"+nodeid+"|"+active) let nd = TW.partialGraph.graph.nodes(nodeid)
var nd = TW.partialGraph.graph.nodes(nodeid)
// TODO harmonize with other status => bien re-distinguer neighbor et active
// nd.active=active;
// console.log('justHover', justHover) nd.customAttrs.forceLabel = true
// var t0, t1
if (justHover) { if (justHover) {
// using single node redraw in hover layer (much faster ~ 0.5ms) // using single node redraw in hover layer (much faster ~ 0.5ms)
...@@ -461,7 +457,7 @@ function LevelButtonDisable( TF ){ ...@@ -461,7 +457,7 @@ function LevelButtonDisable( TF ){
// NB: we just change the flags, not the colors // NB: we just change the flags, not the colors
// renderer will see the flags and handle the case accordingly // renderer will see the flags and handle the case accordingly
// £TODO rendering optimization: reduce effort by looping only on previously selected and neighbors // ££TODO rendering optimization: reduce effort by looping only on previously selected and neighbors
// and having (!active && !highlight) tested instead of then useless grey flag // and having (!active && !highlight) tested instead of then useless grey flag
function greyEverything(){ function greyEverything(){
...@@ -470,10 +466,8 @@ function greyEverything(){ ...@@ -470,10 +466,8 @@ function greyEverything(){
if (n && !n.hidden) { if (n && !n.hidden) {
// normal case handled by node renderers // normal case handled by node renderers
// will see the n.customAttrs.grey flag => use n.customAttrs.defgrey_color // will trigger defgrey_color if (!active && !highlight)
n.customAttrs.grey=1 n.customAttrs.active = false
n.active = false
n.customAttrs.forceLabel = false; n.customAttrs.forceLabel = false;
n.customAttrs.highlight = false; n.customAttrs.highlight = false;
} }
...@@ -482,8 +476,7 @@ function greyEverything(){ ...@@ -482,8 +476,7 @@ function greyEverything(){
if (TW.partialGraph.settings('drawEdges')) { if (TW.partialGraph.settings('drawEdges')) {
for(var i in TW.edgeIds){ for(var i in TW.edgeIds){
let e = TW.partialGraph.graph.edges(TW.edgeIds[i]) let e = TW.partialGraph.graph.edges(TW.edgeIds[i])
if (e && !e.hidden && !e.customAttrs.grey) { if (e && !e.hidden && e.customAttrs.activeEdge) {
e.customAttrs.grey = 1
e.customAttrs.activeEdge = 0 e.customAttrs.activeEdge = 0
} }
} }
...@@ -508,7 +501,6 @@ function prepareNodesRenderingProperties(nodesDict) { ...@@ -508,7 +501,6 @@ function prepareNodesRenderingProperties(nodesDict) {
n.size = Math.round(n.size*sizeFactor*1000)/1000 n.size = Math.round(n.size*sizeFactor*1000)/1000
// new initial setup of properties // new initial setup of properties
n.active = false
var rgba, rgbStr, invalidFormat = false; var rgba, rgbStr, invalidFormat = false;
...@@ -551,8 +543,8 @@ function prepareNodesRenderingProperties(nodesDict) { ...@@ -551,8 +543,8 @@ function prepareNodesRenderingProperties(nodesDict) {
n.customAttrs = { n.customAttrs = {
// status flags // status flags
grey: false, // deselected active: false, // when selected
highlight: false, // neighbors or legend's click highlight: false, // when neighbors or legend's click
// default unselected color // default unselected color
defgrey_color : "rgba("+rgbStr+","+TW.conf.sigmaJsDrawingProperties.twNodesGreyOpacity+")", defgrey_color : "rgba("+rgbStr+","+TW.conf.sigmaJsDrawingProperties.twNodesGreyOpacity+")",
...@@ -565,14 +557,13 @@ function prepareNodesRenderingProperties(nodesDict) { ...@@ -565,14 +557,13 @@ function prepareNodesRenderingProperties(nodesDict) {
// POSS n.type: distinguish rendtype and twtype // POSS n.type: distinguish rendtype and twtype
// POSS flags like this // POSS flags like this
// // sigma's flags: active and hidden // // sigma's flag: hidden (not used)
// active: false,
// hidden: false, // hidden: false,
// customFlags : { // customFlags : {
// // our status flags // // our status flags
// grey: false, // active: false,
// highlight: false, // highlight: false,
// // forceLabel: false, // forceLabel: false,
// } // }
} }
} }
...@@ -588,7 +579,6 @@ function prepareEdgesRenderingProperties(edgesDict, nodesDict) { ...@@ -588,7 +579,6 @@ function prepareEdgesRenderingProperties(edgesDict, nodesDict) {
e.color = "rgba("+rgbStr+","+TW.conf.sigmaJsDrawingProperties.twEdgeDefaultOpacity+")" e.color = "rgba("+rgbStr+","+TW.conf.sigmaJsDrawingProperties.twEdgeDefaultOpacity+")"
e.customAttrs = { e.customAttrs = {
grey: false,
activeEdge : false, activeEdge : false,
true_color : e.color, true_color : e.color,
rgb : rgbStr rgb : rgbStr
......
...@@ -74,7 +74,7 @@ var SigmaUtils = function () { ...@@ -74,7 +74,7 @@ var SigmaUtils = function () {
var fontSize, var fontSize,
prefix = settings('prefix') || '', prefix = settings('prefix') || '',
size = node[prefix + 'size'], size = node[prefix + 'size'],
activeFlag = node['active'] || node.customAttrs['forceLabel'], activeFlag = node.customAttrs['active'] || node.customAttrs['forceLabel'],
neighborFlag = node.customAttrs['highlight'], neighborFlag = node.customAttrs['highlight'],
labelColor = (settings('labelColor') === 'node') ? labelColor = (settings('labelColor') === 'node') ?
(node.color || settings('defaultNodeColor')) : (node.color || settings('defaultNodeColor')) :
...@@ -153,7 +153,7 @@ var SigmaUtils = function () { ...@@ -153,7 +153,7 @@ var SigmaUtils = function () {
} }
else if (neighborFlag) { else if (neighborFlag) {
// larger neighbors or highlight // larger neighbors or highlight
fontSize *= 1.4 fontSize *= 1.3
} }
context.font = (settings('fontStyle') ? settings('fontStyle') + ' ' : '') + context.font = (settings('fontStyle') ? settings('fontStyle') + ' ' : '') +
...@@ -191,12 +191,8 @@ var SigmaUtils = function () { ...@@ -191,12 +191,8 @@ var SigmaUtils = function () {
// console.debug(`t=${tstamp()} curve render activeedge: ${edgeInfos(edge)})`) // console.debug(`t=${tstamp()} curve render activeedge: ${edgeInfos(edge)})`)
} }
else if (edge.customAttrs.grey) {
color = settings('twEdgeGreyColor')
size = 1
}
else { else {
color = "rgba( "+baseRGB+" , "+TW.conf.sigmaJsDrawingProperties.twEdgeDefaultOpacity+")"; color = settings('twEdgeGreyColor')
size = defSize size = defSize
} }
...@@ -243,13 +239,8 @@ var SigmaUtils = function () { ...@@ -243,13 +239,8 @@ var SigmaUtils = function () {
// cf. sigmaTools.edgeColor // cf. sigmaTools.edgeColor
color = 'rgba('+rgb.join()+',.7)' color = 'rgba('+rgb.join()+',.7)'
} }
else if (edge.customAttrs.grey) {
color = settings('twEdgeGreyColor')
size = 1
}
else { else {
// color = "rgba( "+rgb.join()+" , "+TW.conf.sigmaJsDrawingProperties.twEdgeDefaultOpacity+")"; color = settings('twEdgeGreyColor')
color = edge.customAttrs.true_color
size = defSize size = defSize
} }
...@@ -302,9 +293,23 @@ var SigmaUtils = function () { ...@@ -302,9 +293,23 @@ var SigmaUtils = function () {
// mode variants 2: if node is selected, highlighted or unselected // mode variants 2: if node is selected, highlighted or unselected
if (TW.gui.selectionActive) { if (TW.gui.selectionActive) {
// the selected node(s)
if (node.customAttrs.active) {
// called by label+background overlay cf. "subcall"
nodeSize *= 1.1
borderSize *= 1.1
nodeColor = "#222" // metro ticket
}
// the neighbor node(s)
else if (node.customAttrs.highlight) {
nodeSize *= 1.3
borderSize *= 1.3
}
// passive nodes should blend in the grey of twEdgeGreyColor // passive nodes should blend in the grey of twEdgeGreyColor
// cf settings_explorerjs, defgrey_color and greyEverything() // cf settings_explorerjs, defgrey_color and greyEverything()
if (node.customAttrs.grey) { else {
if (! TW.gui.handpickedcolor) { if (! TW.gui.handpickedcolor) {
nodeColor = node.customAttrs.defgrey_color nodeColor = node.customAttrs.defgrey_color
} }
...@@ -314,20 +319,11 @@ var SigmaUtils = function () { ...@@ -314,20 +319,11 @@ var SigmaUtils = function () {
// nice looking uniform grey // nice looking uniform grey
borderColor = TW.conf.sigmaJsDrawingProperties.twBorderGreyColor borderColor = TW.conf.sigmaJsDrawingProperties.twBorderGreyColor
} }
else {
nodeSize *= 1.4
borderSize *= 1.4
if(node.active) {
// called by label+background overlay cf. "subcall"
nodeColor = "#222" // metro ticket
}
}
} }
// highlight AND (NOT selectionActive) => highlight just this one time // highlight AND (NOT selectionActive) => highlight just this one time
else if (node.customAttrs.highlight) { else if (node.customAttrs.highlight) {
nodeSize *= 1.4 nodeSize *= 1.3
borderSize *= 1.4 borderSize *= 1.3
node.customAttrs.highlight = false node.customAttrs.highlight = false
} }
...@@ -408,8 +404,8 @@ var SigmaUtils = function () { ...@@ -408,8 +404,8 @@ var SigmaUtils = function () {
settings('labelSizeRatio') * size; settings('labelSizeRatio') * size;
// largerall: our customized size boosts // largerall: our customized size boosts
if (!node.active) { if (!node.customAttrs.active) {
fontSize *= 1.4 fontSize *= 1.3
let X = node[prefix + 'x'] let X = node[prefix + 'x']
let Y = node[prefix + 'y'] let Y = node[prefix + 'y']
......
...@@ -25,10 +25,9 @@ sigmaTools = (function(stools) { ...@@ -25,10 +25,9 @@ sigmaTools = (function(stools) {
y: rawNode.viz.position.y, y: rawNode.viz.position.y,
color: rawNode.viz.color, color: rawNode.viz.color,
size: Math.round(rawNode.viz.size*1000)/1000, size: Math.round(rawNode.viz.size*1000)/1000,
active: false,
hidden: false, hidden: false,
customAttrs: { customAttrs: {
grey: false, active: false,
highlight: false, highlight: false,
defgrey_color : "rgba("+rgbStr+",.4)" defgrey_color : "rgba("+rgbStr+",.4)"
}, },
...@@ -54,7 +53,6 @@ sigmaTools = (function(stools) { ...@@ -54,7 +53,6 @@ sigmaTools = (function(stools) {
color: leColor, color: leColor,
weight: Math.round(rawEdge.weight*1000)/1000, weight: Math.round(rawEdge.weight*1000)/1000,
customAttrs: { customAttrs: {
grey: false,
activeEdge: false, activeEdge: false,
true_color: leColor, true_color: leColor,
rgb: rgbStr rgb: rgbStr
......
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