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

functional area select (TODO fix some deselect glitches)

parent 7af0b354
...@@ -438,23 +438,29 @@ function circleTrackMouse(e) { ...@@ -438,23 +438,29 @@ function circleTrackMouse(e) {
ctx.globalAlpha = 0.5; ctx.globalAlpha = 0.5;
ctx.beginPath(); ctx.beginPath();
// // labels appear on circle hover : OFF
// convert (TODO CHECK IN THIS CONTEXT) // convert (TODO CHECK IN THIS CONTEXT)
var camCoords = TW.cam.cameraPosition(x,y) // var camCoords = TW.cam.cameraPosition(x,y)
var exactNodeset = circleGetAreaNodes(
camCoords.x,
camCoords.y
)
// TODO REFA UNCOMMENT pseudo hover
// labels appear
// //
// if(TW.partialGraph.camera.ratio > showLabelsIfZoom){ // var exactNodeset = circleGetAreaNodes(
// for n of exactNodeset // camCoords.x,
// n.forceLabel=true; // camCoords.y
// )
// // using settings_explorerjs.showLabelsIfZoom as cam.ratio threshold
// if(TW.partialGraph.camera.ratio < showLabelsIfZoom){
// for (var k of exactNodeset) {
// // if (! exactNodeset[k].hidden) {
// exactNodeset[k].forceLabel=true;
// // }
// }
// } // }
// else { // else {
// for(var i in exactNodeset){ // for(var k in exactNodeset){
// n = exactNodeset[k]
// n.forceLabel=false; // n.forceLabel=false;
//
// // ?deprecated?
// if(typeof(n.neighbour)!=="undefined") { // if(typeof(n.neighbour)!=="undefined") {
// if(!n.neighbour) n.forceLabel=false; // if(!n.neighbour) n.forceLabel=false;
// else n.forceLabel=true; // else n.forceLabel=true;
...@@ -478,34 +484,42 @@ function circleTrackMouse(e) { ...@@ -478,34 +484,42 @@ function circleTrackMouse(e) {
// exact subset of nodes under circle // exact subset of nodes under circle
function circleGetAreaNodes(camX0, camY0) { function circleGetAreaNodes(camX0, camY0) {
// leverage quadtree to get a neighborhood var cursor_ray = cursor_size * TW.cam.ratio // cursor_size to cam units
// prepare an approximate neighborhood
var slightlyLargerNodeset = circleLocalSubset( var slightlyLargerNodeset = circleLocalSubset(
camX0, camX0, camY0,
camY0, cursor_ray
cursor_size * TW.cam.ratio // cursor_size to cam units
) )
console.log('slightlyLargerNodeset', slightlyLargerNodeset)
var exactNodeset = [] var exactNodeset = []
for(var i in slightlyLargerNodeset){ for(var i in slightlyLargerNodeset){
n = slightlyLargerNodeset[i]; n = slightlyLargerNodeset[i];
if(n.hidden==false){ if(!n.hidden){
distance = Math.sqrt( distance = Math.sqrt(
Math.pow((x-parseInt(n.displayX)),2) + Math.pow((camX0-parseInt(n['read_cam0:x'])),2) +
Math.pow((y-parseInt(n.displayY)),2) Math.pow((camY0-parseInt(n['read_cam0:y'])),2)
); );
if(parseInt(distance)<=cursor_size) {
exactNodeset.push. // console.log('D[P0,'+n.label+'] =', distance)
} else {
if(typeof(n.neighbour)!=="undefined") { if( distance <= cursor_ray) {
if(!n.neighbour) n.forceLabel=false; exactNodeset.push(n.id)
} else n.forceLabel=false;
}
}
} }
if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) { else {
TW.partialGraph.refresh({skipIndexation:true}) // ?deprecated?
if(typeof(n.neighbour)!=="undefined") {
if(!n.neighbour) n.forceLabel=false;
} else n.forceLabel=false;
} }
}
}
if(TW.partialGraph.forceatlas2 && TW.partialGraph.forceatlas2.count<=1) {
TW.partialGraph.refresh({skipIndexation:true})
}
return exactNodeset return exactNodeset
} }
......
...@@ -260,7 +260,7 @@ SelectionEngine = function() { ...@@ -260,7 +260,7 @@ SelectionEngine = function() {
/** /**
* Main function for any selecting action * Main function for any selecting action
* *
* @nodes: eg targeted array * @nodes: eg targeted array (only ids)
*/ */
// external usage : partialGraph , updateLeftPanel_fix(); // external usage : partialGraph , updateLeftPanel_fix();
this.MultipleSelection2 = (function(nodes,nodesDict,edgesDict) { this.MultipleSelection2 = (function(nodes,nodesDict,edgesDict) {
...@@ -681,7 +681,12 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -681,7 +681,12 @@ 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
// ---------------------
// new sigma.js: sigma events bindings
// ---------------------
// cf. https://github.com/jacomyal/sigma.js/wiki/Events-API // cf. https://github.com/jacomyal/sigma.js/wiki/Events-API
// cases: // cases:
...@@ -718,7 +723,11 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -718,7 +723,11 @@ TinaWebJS = function ( sigmacanvas ) {
// circleNodes += prevsels // circleNodes += prevsels
// 2) show selection + do all related effects // 2) show selection + do all related effects
SelInst.MultipleSelection2({nodes:circleNodes}) cancelSelection()
if (circleNodes.length) {
SelInst.MultipleSelection2({nodes:circleNodes})
}
} }
}) })
......
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