From 0160f56238b4ffaf8f69f2ef69e36e22f729a675 Mon Sep 17 00:00:00 2001 From: Robert Best Date: Fri, 26 Sep 2014 22:40:31 -0400 Subject: [PATCH] partially finished fixes to zoomextents --- app/assets/javascripts/metamaps/JIT.js | 6 ++ .../javascripts/metamaps/Metamaps.GlobalUI.js | 17 ++++ .../javascripts/metamaps/Metamaps.JIT.js | 90 +++++++++++++++---- app/assets/javascripts/metamaps/Metamaps.js | 3 + 4 files changed, 99 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/metamaps/JIT.js b/app/assets/javascripts/metamaps/JIT.js index de6aacb7..c43788bc 100644 --- a/app/assets/javascripts/metamaps/JIT.js +++ b/app/assets/javascripts/metamaps/JIT.js @@ -2489,7 +2489,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(); @@ -2557,6 +2561,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/metamaps/Metamaps.GlobalUI.js b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js index 13278b28..f1c40b25 100644 --- a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js @@ -372,6 +372,23 @@ Metamaps.GlobalUI.Search = { self.close(0, true); } break; + case 65: + case 97: + e.preventDefault(); + if (e.ctrlKey){ + Metamaps.Visualize.mGraph.graph.eachNode(function (n) { + Metamaps.Control.selectNode(n,e); + }); + + Metamaps.Visualize.mGraph.plot(); + } + + break; + case 69: + case 101: + e.preventDefault(); + Metamaps.JIT.zoomExtents(); + break; default: break; //console.log(e.which); } diff --git a/app/assets/javascripts/metamaps/Metamaps.JIT.js b/app/assets/javascripts/metamaps/Metamaps.JIT.js index c0250038..810f2b2e 100644 --- a/app/assets/javascripts/metamaps/Metamaps.JIT.js +++ b/app/assets/javascripts/metamaps/Metamaps.JIT.js @@ -313,7 +313,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; } @@ -663,8 +663,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); } @@ -945,7 +943,9 @@ 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 from = synapse.get('edge').nodeFrom; + var to = synapse.get('edge').nodeTo; + var maxX = fromNodeX; var maxY = fromNodeY; var minX = fromNodeX; @@ -964,7 +964,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) ); @@ -983,6 +983,10 @@ Metamaps.JIT = { var b = fromNodeY - synSlope * fromNodeX; var selectTest = false; + if (from.name == 'node 3' && to.name == 'node1'){ + console.log(from.pos.x,-1*from.pos.y,to.pos.x,-1*to.pos.y,sX,sY,eX,eY); + } + //if the synapse slope is within a range that would intersect with the selection box if (synSlope <= maxSlope && synSlope >= minSlope){ @@ -1003,17 +1007,18 @@ Metamaps.JIT = { testY = sY; testX = (testY - b)/synSlope; - if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ + 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 && testY <= maxBoxX){ + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){ selectTest = true; } } + //console.log('From '+from.name + ' to ' + to.name + ' is a ' +selectTest); //The test synapse was selected! if(selectTest){ if(e.ctrlKey){ @@ -1078,15 +1083,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'], @@ -1111,7 +1124,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 = '