diff --git a/app/assets/javascripts/src/JIT.js b/app/assets/javascripts/src/JIT.js index 843f1fa8..1cc4b8e1 100644 --- a/app/assets/javascripts/src/JIT.js +++ b/app/assets/javascripts/src/JIT.js @@ -2498,7 +2498,11 @@ Extras.Classes.Navigation = new Class({ if (!Metamaps.Mouse.boxStartCoordinates && (e.shiftKey || rightClick)) { Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos(); } + Metamaps.Mouse.didPan = false; + + + // END METAMAPS CODE this.pos = eventInfo.getPos(); @@ -2570,6 +2574,8 @@ Extras.Classes.Navigation = new Class({ // START METAMAPS CODE if (Metamaps.Mouse.didPan) Metamaps.JIT.SmoothPanning(); + + // END METAMAPS CODE } diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js b/app/assets/javascripts/src/Metamaps.GlobalUI.js index fc8f46ea..a425d78f 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js @@ -366,6 +366,29 @@ Metamaps.GlobalUI.Search = { self.close(0, true); } break; + case 65: + case 97: + + if (e.ctrlKey){ + Metamaps.Control.deselectAllNodes(); + Metamaps.Control.deselectAllEdges(); + + e.preventDefault(); + Metamaps.Visualize.mGraph.graph.eachNode(function (n) { + Metamaps.Control.selectNode(n,e); + }); + + Metamaps.Visualize.mGraph.plot(); + } + + break; + case 69: + case 101: + if (e.ctrlKey){ + e.preventDefault(); + Metamaps.JIT.zoomExtents(); + } + break; default: break; //console.log(e.which); } diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index ee405736..41481c56 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -319,7 +319,7 @@ Metamaps.JIT = { if (Metamaps.Mouse.boxStartCoordinates) { Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); - Metamaps.JIT.selectWithBox(e); + Metamaps.JIT.zoomToBox(); return; } @@ -672,8 +672,6 @@ Metamaps.JIT = { var scale = dist / lastDist; - console.log(scale); - if (8 >= Metamaps.Visualize.mGraph.canvas.scaleOffsetX * scale && Metamaps.Visualize.mGraph.canvas.scaleOffsetX * scale >= 1) { Metamaps.Visualize.mGraph.canvas.scale(scale, scale); } @@ -940,7 +938,7 @@ Metamaps.JIT = { Metamaps.Control.deselectAllEdges(); } - //select all nodes, and their edges, that are within the box + //select all nodes that are within the box Metamaps.Visualize.mGraph.graph.eachNode(function (n) { var x = n.pos.x, y = n.pos.y; @@ -969,8 +967,8 @@ Metamaps.JIT = { var fromNodeY = -1 * synapse.get('edge').nodeFrom.pos.y; var toNodeX = synapse.get('edge').nodeTo.pos.x; var toNodeY = -1 * synapse.get('edge').nodeTo.pos.y; - - var maxX = fromNodeX; + + var maxX = fromNodeX; var maxY = fromNodeY; var minX = fromNodeX; var minY = fromNodeY; @@ -988,7 +986,7 @@ Metamaps.JIT = { (eX > maxBoxX) ? (maxBoxX = eX):(minBoxX = eX); (eY > maxBoxY) ? (maxBoxY = eY):(minBoxY = eY); - //Fins the slopes from the synapse fromNode to the 4 corners of the selection box + //Find the slopes from the synapse fromNode to the 4 corners of the selection box var slopes = []; slopes.push( (sY - fromNodeY) / (sX - fromNodeX) ); slopes.push( (sY - fromNodeY) / (eX - fromNodeX) ); @@ -1005,40 +1003,44 @@ Metamaps.JIT = { //Find synapse-in-question's slope var synSlope = (toNodeY - fromNodeY) / (toNodeX - fromNodeX); var b = fromNodeY - synSlope * fromNodeX; + + //Use the selection box edges as test cases for synapse intersection + var testX = sX; + var testY = synSlope * testX + b; + + var selectTest; - var selectTest = false; - - //if the synapse slope is within a range that would intersect with the selection box - if (synSlope <= maxSlope && synSlope >= minSlope){ - var testX = sX; - var testY = synSlope * testX + b; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ - selectTest = true; - } - - testX = eX; - testY = synSlope * testX + b; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ - selectTest = true; - } - - testY = sY; - testX = (testY - b)/synSlope; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ - selectTest = true; - } - - testY = eY; - testX = (testY - b)/synSlope; - - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ - selectTest = true; - } + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ + selectTest = true; } - //The test synapse was selected! + + testX = eX; + testY = synSlope * testX + b; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ + selectTest = true; + } + + testY = sY; + testX = (testY - b)/synSlope; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ + selectTest = true; + } + + testY = eY; + testX = (testY - b)/synSlope; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ + selectTest = true; + } + + //Case where the synapse is wholly enclosed in the seldction box + if(fromNodeX >= minBoxX && fromNodeX <= maxBoxX && fromNodeY >= minBoxY && fromNodeY <= maxBoxY && toNodeX >= minBoxX && toNodeX <= maxBoxX && toNodeY >= minBoxY && toNodeY <= maxBoxY){ + selectTest = true; + } + + //The test synapse was selected! if(selectTest){ if(e.ctrlKey){ if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ @@ -1102,15 +1104,23 @@ Metamaps.JIT = { // wait a certain length of time, then check again, then run this code setTimeout(function () { if (!Metamaps.JIT.nodeWasDoubleClicked()) { - if (!e.shiftKey) { + if (!e.shiftKey && !e.ctrlKey) { Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllEdges(); } - if (node.selected) { - Metamaps.Control.deselectNode(node); - } else { + if(e.ctrlKey || e.shiftKey){ + if (node.selected) { + Metamaps.Control.deselectNode(node); + } else { + Metamaps.Control.selectNode(node,e); + } + } + else{ + Metamaps.Control.deselectAllNodes(); + Metamaps.Control.deselectAllEdges(); Metamaps.Control.selectNode(node,e); } + //trigger animation to final styles Metamaps.Visualize.mGraph.fx.animate({ modes: ['edge-property:lineWidth:color:alpha'], @@ -1138,7 +1148,6 @@ Metamaps.JIT = { // create new menu for clicked on node var rightclickmenu = document.createElement("div"); rightclickmenu.className = "rightclickmenu"; - // add the proper options to the menu var menustring = '