Commit 81c46e79 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[SELECTOR WIP]

parent 98537466
...@@ -69,76 +69,72 @@ exports.pauseForceAtlas2 = function() { ...@@ -69,76 +69,72 @@ exports.pauseForceAtlas2 = function() {
exports.cursor_size = 10; exports.cursor_size = 10;
// TODO // TODO
// exports.shift_key = false; exports.shift_key = false;
exports.shift_key = true; //exports.shift_key = true;
exports.trackMouse = function() { exports.trackMouse = function(e) {
var partialGraph = window.sigmaGargInstance; var partialGraph = window.sigmaGargInstance;
console.log('FUN t.minimap:trackMouse') console.log('FUN t.minimap:trackMouse');
if(!exports.shift_key) { if(!exports.shift_key) {
// $.doTimeout(300,function (){ // new sigma.js 2D mouse context
var ctx = partialGraph._core.domElements.mouse.getContext('2d'); var ctx = partialGraph.renderers[0].contexts.mouse;
ctx.globalCompositeOperation = "source-over"; ctx.globalCompositeOperation = "source-over";
ctx.clearRect(0, 0, partialGraph._core.domElements.nodes.width, partialGraph._core.domElements.nodes.height);
// clear zone each time to prevent repeated frame artifacts
x = partialGraph._core.mousecaptor.mouseX; ctx.clearRect(50, 50,
y = partialGraph._core.mousecaptor.mouseY; partialGraph.renderers[0].container.offsetWidth,
partialGraph.renderers[0].container.offsetHeight);
ctx.strokeStyle = '#000';
ctx.lineWidth = 1; // classic mousemove event or other similar non-sigma events
ctx.fillStyle = "#71C3FF";
ctx.globalAlpha = 0.5; var coord = window.sigma.utils.mouseCoords(e)
ctx.beginPath(); var x = (coord.x + coord.clientX) / 2 // ; // sigma.utils.getX(e);
var y = (coord.y + coord.clientY) /2 // ; // sigma.utils.getY(e);
if(partialGraph._core.mousecaptor.ratio>showLabelsIfZoom){ console.log(coord);
for(var i in partialGraph._core.graph.nodesIndex){ // optional: make more labels appear on circle hover (/!\ costly /!\ esp. on large graphs)
n=partialGraph._core.graph.nodesIndex[i]; // if (partialGraph.conf.moreLabelsUnderArea) {
if(n.hidden==false){ // // convert screen => mouse => cam
distance = Math.sqrt( // var mouseCoords = (50,50); // sigma.utils.mouseCoords(e)
Math.pow((x-parseInt(n.displayX)),2) + // var camCoords = partialGraph.cam.cameraPosition(mouseCoords.x, mouseCoords.y)
Math.pow((y-parseInt(n.displayY)),2) //
); // var exactNodeset = circleGetAreaNodes(camCoords.x,camCoords.y)
if(parseInt(distance)<=exports.cursor_size) { // // console.log("nodes under circle:", exactNodeset)
partialGraph._core.graph.nodesIndex[i].forceLabel=true; //
} else { // // we'll use labelThreshold / 3 as the "boosted" cam:size threshold
if(typeof(n.neighbour)!=="undefined") { // var pfx = partialGraph.cam.readPrefix
if(!n.neighbour) partialGraph._core.graph.nodesIndex[i].forceLabel=false; // var toRedraw = []
} else partialGraph._core.graph.nodesIndex[i].forceLabel=false; // for (var k in exactNodeset) {
} // var n = partialGraph.graph.nodes(exactNodeset[k])
} // if(!n.hidden && n[pfx+'size'] > (partialGraph.customSettings.labelThreshold / 3)) {
} // toRedraw.push(n)
if(partialGraph.forceatlas2 && partialGraph.forceatlas2.count<=1) { // }
partialGraph.draw(2,2,2); // }
} // redrawNodesInHoverLayer(toRedraw, "hovers")
} else { // }
for(var i in partialGraph._core.graph.nodesIndex){
n=partialGraph._core.graph.nodesIndex[i]; // draw the circle itself
if(!n.hidden){ ctx.strokeStyle = '#000';
partialGraph._core.graph.nodesIndex[i].forceLabel=false; ctx.lineWidth = 1;
if(typeof(n.neighbour)!=="undefined") { ctx.fillStyle = "#71C3FF";
if(!n.neighbour) partialGraph._core.graph.nodesIndex[i].forceLabel=false; ctx.globalAlpha = 0.5;
else partialGraph._core.graph.nodesIndex[i].forceLabel=true; ctx.beginPath();
} else partialGraph._core.graph.nodesIndex[i].forceLabel=false; ctx.arc(x, y, 30.0, 0, Math.PI * 2, true);
} //ctx.arc(x, y, partialGraph.gui.circleSize, 0, Math.PI * 2, true);
} ctx.closePath();
if(partialGraph.forceatlas2 && partialGraph.forceatlas2.count<=1) { ctx.fill();
partialGraph.draw(2,2,2); ctx.stroke();
} ctx.globalAlpha = 1
}
ctx.arc(x, y, exports.cursor_size, 0, Math.PI * 2, true);
//ctx.arc(partialGraph._core.width/2, partialGraph._core.height/2, 4, 0, 2 * Math.PI, true);/*todel*/
ctx.closePath();
ctx.fill();
ctx.stroke();
// });
} }
}; };
exports.sigmaOnMouseMove = function(e) { exports.sigmaOnMouseMove = function(e) {
return function() { return function() {
console.log('sigmaOnMouseMove'); console.log('sigmaOnMouseMove');
if(typeof(window.sigmaGargInstance) !== "undefined") { if(typeof(window.sigmaGargInstance) !== "undefined") {
if(exports.cursor_size>0) exports.trackMouse(); if(exports.cursor_size>0) exports.trackMouse(e);
} }
}; };
}; };
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