Commit de26dc86 authored by Romain Loth's avatar Romain Loth

WIP port: new sigma allows a simpler click one node -> MultipleSelection (no...

WIP port: new sigma allows a simpler click one node -> MultipleSelection (no need for selectionEngine at all for one node)
parent a5da94eb
...@@ -54,6 +54,10 @@ function sigmaLimits( sigmacanvas ) { ...@@ -54,6 +54,10 @@ function sigmaLimits( sigmacanvas ) {
// will be instanciated as SelInst // will be instanciated as SelInst
SelectionEngine = function() { SelectionEngine = function() {
// TODO REFA this block was used for area selection
// (!at least partly replaceable by getNodes from new sigma.misc.bindEvents)
// ----------------------------------------------------------8<-------------
// Selection Engine!! finally... // Selection Engine!! finally...
this.SelectorEngine_part01 = (function(cursorsize, area ) { this.SelectorEngine_part01 = (function(cursorsize, area ) {
var clickedNodes = [] var clickedNodes = []
...@@ -126,6 +130,7 @@ SelectionEngine = function() { ...@@ -126,6 +130,7 @@ SelectionEngine = function() {
return targeted; return targeted;
}).index(); }).index();
// ----------------------------------------------------------8<-------------
this.SelectorEngine = (function( cursorsize , area , addvalue , clicktype , prevsels , currsels ) { this.SelectorEngine = (function( cursorsize , area , addvalue , clicktype , prevsels , currsels ) {
var targeted = [] var targeted = []
...@@ -311,7 +316,7 @@ SelectionEngine = function() { ...@@ -311,7 +316,7 @@ SelectionEngine = function() {
this.MultipleSelection2 = (function(nodes,nodesDict,edgesDict) { this.MultipleSelection2 = (function(nodes,nodesDict,edgesDict) {
console.log("IN SelectionEngine.MultipleSelection2:") console.log("IN SelectionEngine.MultipleSelection2:")
// console.log(nodes) console.log("nodes", nodes)
greyEverything(); greyEverything();
// TW.partialGraph.states.slice(-1)[0] is the present graph state // TW.partialGraph.states.slice(-1)[0] is the present graph state
...@@ -364,7 +369,7 @@ SelectionEngine = function() { ...@@ -364,7 +369,7 @@ SelectionEngine = function() {
} }
} }
for(var i in edges_2_colour) { for(var i in edges_2_colour) {
an_edge = TW.partialGraph.edges(i) an_edge = TW.partialGraph.graph.edges(i)
if(!isUndef(an_edge) && !an_edge.hidden){ if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.customAttrs['true_color']; an_edge.color = an_edge.customAttrs['true_color'];
an_edge.customAttrs['grey'] = 0; an_edge.customAttrs['grey'] = 0;
...@@ -409,7 +414,7 @@ SelectionEngine = function() { ...@@ -409,7 +414,7 @@ SelectionEngine = function() {
overNodes=true; overNodes=true;
TW.partialGraph.draw(); TW.partialGraph.refresh({skipIndexation:true});
updateLeftPanel_fix( selections , oppos ); updateLeftPanel_fix( selections , oppos );
...@@ -419,6 +424,10 @@ SelectionEngine = function() { ...@@ -419,6 +424,10 @@ SelectionEngine = function() {
}).index() }).index()
}; };
// REFA tempo expose selectionEngine and methods
var SelInst
TinaWebJS = function ( sigmacanvas ) { TinaWebJS = function ( sigmacanvas ) {
this.sigmacanvas = sigmacanvas; this.sigmacanvas = sigmacanvas;
...@@ -440,7 +449,9 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -440,7 +449,9 @@ TinaWebJS = function ( sigmacanvas ) {
this.SearchListeners = function () { this.SearchListeners = function () {
var SelInst = new SelectionEngine(); // REFA tempo expose
// var SelInst = new SelectionEngine();
SelInst = new SelectionEngine();
//~ $.ui.autocomplete.prototype._renderItem = function(ul, item) { //~ $.ui.autocomplete.prototype._renderItem = function(ul, item) {
//~ var searchVal = $("#searchinput").val(); //~ var searchVal = $("#searchinput").val();
...@@ -724,33 +735,43 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -724,33 +735,43 @@ TinaWebJS = function ( sigmacanvas ) {
partialGraph.camera.goTo({x:0, y:0, ratio:1}) partialGraph.camera.goTo({x:0, y:0, ratio:1})
}); });
// new sigma.js: attempt to use sigma events bindings
// cases:
// [DONE] - simple click, one node
// [TODO] - simple click, area
// new sigma.js: attempt to use sigma events bindings // one node:
TW.partialGraph.bind('clickNode', function(e, node) {
// new sigma.js gives easy access to clicked node!
theNodeId = e.data.node.id
cancelSelection(false);
SelInst.MultipleSelection2({nodes:[theNodeId]})
})
// TODO // TODO
TW.partialGraph.bind('click', function(e) { // TW.partialGraph.bind('click', function(e) {
console.log("===click==="); // console.log("===click===");
console.log("e", e); // console.log("e", e);
}) // })
TW.partialGraph.bind('clickNode', function(e) {
console.log("===clickNode==="); // TW.partialGraph.bind('downgraph upgraph', function(e) {
console.log("e", e); // console.log("===downgraph upgraph===");
}) // console.log("e", e);
TW.partialGraph.bind('downgraph upgraph', function(e) { // })
console.log("===downgraph upgraph===");
console.log("e", e);
})
// --------------------------------------------fragment from v1.customized // --------------------------------------------fragment from v1.customized
// }).bind('mousedown mouseup', function(e) { // TW.partialGraph.bind('mousedown mouseup', function(e) {
// var targeted = self.graph.nodes.filter(function(n) { //
// return !!n['hover']; // console.log("---------- event", e)
// }).map(function(n) { // var targeted = self.graph.nodes.filter(function(n) {
// return n.id; // return !!n['hover'];
// }); // }).map(function(n) {
// return n.id;
// });
// console.log("---------- targeted by hover check loop", targeted)
// })
// //
// self.dispatch( // self.dispatch(
// e['type'] == 'mousedown' ? // e['type'] == 'mousedown' ?
...@@ -765,8 +786,8 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -765,8 +786,8 @@ TinaWebJS = function ( sigmacanvas ) {
// 'upnodes', // 'upnodes',
// targeted // targeted
// ); // );
// }
// } // }
// }).bind('move', function() {
// -------------------------------------------/fragment from v1.customized // -------------------------------------------/fragment from v1.customized
......
...@@ -358,14 +358,17 @@ if(RES["OK"]) { ...@@ -358,14 +358,17 @@ if(RES["OK"]) {
bgcolor:"#FFA500", bgcolor:"#FFA500",
onchange:function(value){ onchange:function(value){
$.doTimeout(100,function (){ $.doTimeout(100,function (){
TW.partialGraph.iterNodes(function (n) { // POSS: custom index by n.type
if(TW.Nodes[n.id].type==TW.catSem) { var nds = TW.partialGraph.graph.nodes()
var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3 for (var j in nds) {
n.size = (newval<1.0)?1:newval; var n = nds[j]
sizeMult[TW.catSem] = parseFloat(value-1)*0.3; 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;
TW.partialGraph.draw(); sizeMult[TW.catSem] = parseFloat(value-1)*0.3;
}
}
TW.partialGraph.refresh({skipIndexation:true});
}); });
} }
}); });
......
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