Merge robs changes
Merge remote-tracking branch 'origin/develop' into new
This commit is contained in:
commit
9cab20dc2a
4 changed files with 128 additions and 19 deletions
2
Gemfile
2
Gemfile
|
@ -7,7 +7,7 @@ gem 'rails', '3.2.17'
|
||||||
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
||||||
|
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
gem 'redis'
|
gem 'redis', '2.2.2'
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
gem 'cancan'
|
gem 'cancan'
|
||||||
gem 'formula'
|
gem 'formula'
|
||||||
|
|
|
@ -117,7 +117,7 @@ GEM
|
||||||
rake (10.3.2)
|
rake (10.3.2)
|
||||||
rdoc (3.12.2)
|
rdoc (3.12.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
redis (3.0.7)
|
redis (2.2.2)
|
||||||
sass (3.3.7)
|
sass (3.3.7)
|
||||||
sass-rails (3.2.6)
|
sass-rails (3.2.6)
|
||||||
railties (~> 3.2.0)
|
railties (~> 3.2.0)
|
||||||
|
@ -160,6 +160,6 @@ DEPENDENCIES
|
||||||
pg
|
pg
|
||||||
rails (= 3.2.17)
|
rails (= 3.2.17)
|
||||||
rails3-jquery-autocomplete
|
rails3-jquery-autocomplete
|
||||||
redis
|
redis (= 2.2.2)
|
||||||
sass-rails
|
sass-rails
|
||||||
uglifier (>= 1.0.3)
|
uglifier (>= 1.0.3)
|
||||||
|
|
|
@ -307,7 +307,7 @@ Metamaps.JIT = {
|
||||||
if (Metamaps.Mouse.boxStartCoordinates) {
|
if (Metamaps.Mouse.boxStartCoordinates) {
|
||||||
Metamaps.Visualize.mGraph.busy = false;
|
Metamaps.Visualize.mGraph.busy = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
||||||
Metamaps.JIT.selectNodesWithBox();
|
Metamaps.JIT.selectNodesWithBox(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ Metamaps.JIT = {
|
||||||
if (Metamaps.Mouse.boxStartCoordinates) {
|
if (Metamaps.Mouse.boxStartCoordinates) {
|
||||||
Metamaps.Visualize.mGraph.busy = false;
|
Metamaps.Visualize.mGraph.busy = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
||||||
Metamaps.JIT.selectNodesWithBox();
|
Metamaps.JIT.selectNodesWithBox(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,12 +885,11 @@ Metamaps.JIT = {
|
||||||
// 4 this node and others were selected, so drag them (just return false)
|
// 4 this node and others were selected, so drag them (just return false)
|
||||||
//return value: deselect node again after?
|
//return value: deselect node again after?
|
||||||
if (Metamaps.Selected.Nodes.length == 0) {
|
if (Metamaps.Selected.Nodes.length == 0) {
|
||||||
Metamaps.Control.selectNode(node);
|
return 'only-drag-this-one';
|
||||||
return 'deselect';
|
|
||||||
}
|
}
|
||||||
if (Metamaps.Selected.Nodes.indexOf(node) == -1) {
|
if (Metamaps.Selected.Nodes.indexOf(node) == -1) {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
Metamaps.Control.selectNode(node);
|
Metamaps.Control.selectNode(node,e);
|
||||||
return 'nothing';
|
return 'nothing';
|
||||||
} else {
|
} else {
|
||||||
return 'only-drag-this-one';
|
return 'only-drag-this-one';
|
||||||
|
@ -898,26 +897,131 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
return 'nothing'; //case 4?
|
return 'nothing'; //case 4?
|
||||||
}, // handleSelectionBeforeDragging
|
}, // handleSelectionBeforeDragging
|
||||||
selectNodesWithBox: function () {
|
selectNodesWithBox: function (e) {
|
||||||
|
|
||||||
var sX = Metamaps.Mouse.boxStartCoordinates.x,
|
var sX = Metamaps.Mouse.boxStartCoordinates.x,
|
||||||
sY = Metamaps.Mouse.boxStartCoordinates.y,
|
sY = Metamaps.Mouse.boxStartCoordinates.y,
|
||||||
eX = Metamaps.Mouse.boxEndCoordinates.x,
|
eX = Metamaps.Mouse.boxEndCoordinates.x,
|
||||||
eY = Metamaps.Mouse.boxEndCoordinates.y;
|
eY = Metamaps.Mouse.boxEndCoordinates.y;
|
||||||
|
|
||||||
|
if(!(e.shiftKey) && !(e.ctrlKey)){
|
||||||
|
Metamaps.Control.deselectAllNodes();
|
||||||
|
Metamaps.Control.deselectAllEdges();
|
||||||
|
}
|
||||||
|
|
||||||
|
//select all nodes, and their edges, that are within the box
|
||||||
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
||||||
var x = n.pos.x,
|
var x = n.pos.x,
|
||||||
y = n.pos.y;
|
y = n.pos.y;
|
||||||
|
|
||||||
if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) {
|
if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) {
|
||||||
var nodeIsSelected = Metamaps.Selected.Nodes.indexOf(n);
|
if(e.ctrlKey){
|
||||||
if (nodeIsSelected == -1) Metamaps.Control.selectNode(n); // the node is not selected, so select it
|
if(n.selected){
|
||||||
else if (nodeIsSelected != -1) Metamaps.Control.deselectNode(n); // the node is selected, so deselect it
|
Metamaps.Control.deselectNode(n);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Metamaps.Control.selectNode(n,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Metamaps.Control.selectNode(n,e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Convert selection box coordinates to traditional coordinates (+,+) in upper right
|
||||||
|
sY = -1 * sY;
|
||||||
|
eY = -1 * eY
|
||||||
|
|
||||||
|
Metamaps.Synapses.each(function(synapse) {
|
||||||
|
var fromNodeX = synapse.get('edge').nodeFrom.pos.x;
|
||||||
|
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 maxY = fromNodeY;
|
||||||
|
var minX = fromNodeX;
|
||||||
|
var minY = fromNodeY;
|
||||||
|
|
||||||
|
//Correct maxX, MaxY values
|
||||||
|
(toNodeX > maxX) ? (maxX = toNodeX):(minX = toNodeX);
|
||||||
|
(toNodeY > maxY) ? (maxY = toNodeY):(minY = toNodeY);
|
||||||
|
|
||||||
|
var maxBoxX = sX;
|
||||||
|
var maxBoxY = sY;
|
||||||
|
var minBoxX = sX;
|
||||||
|
var minBoxY = sY;
|
||||||
|
|
||||||
|
//Correct maxBoxX, maxBoxY values
|
||||||
|
(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
|
||||||
|
var slopes = [];
|
||||||
|
slopes.push( (sY - fromNodeY) / (sX - fromNodeX) );
|
||||||
|
slopes.push( (sY - fromNodeY) / (eX - fromNodeX) );
|
||||||
|
slopes.push( (eY - fromNodeY) / (eX - fromNodeX) );
|
||||||
|
slopes.push( (eY - fromNodeY) / (sX - fromNodeX) );
|
||||||
|
|
||||||
|
var minSlope = slopes[0];
|
||||||
|
var maxSlope = slopes[0];
|
||||||
|
slopes.forEach(function(entry){
|
||||||
|
if(entry > maxSlope) maxSlope = entry;
|
||||||
|
if(entry < minSlope) minSlope = entry;
|
||||||
|
});
|
||||||
|
|
||||||
|
//Find synapse-in-question's slope
|
||||||
|
var synSlope = (toNodeY - fromNodeY) / (toNodeX - fromNodeX);
|
||||||
|
var b = fromNodeY - synSlope * fromNodeX;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//The test synapse was selected!
|
||||||
|
if(selectTest){
|
||||||
|
if(e.ctrlKey){
|
||||||
|
if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){
|
||||||
|
Metamaps.Control.deselectEdge(synapse.get('edge'));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Metamaps.Control.selectEdge(synapse.get('edge'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Metamaps.Control.selectEdge(synapse.get('edge'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Metamaps.Mouse.boxStartCoordinates = false;
|
Metamaps.Mouse.boxStartCoordinates = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = false;
|
Metamaps.Mouse.boxEndCoordinates = false;
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
|
@ -974,7 +1078,7 @@ Metamaps.JIT = {
|
||||||
if (node.selected) {
|
if (node.selected) {
|
||||||
Metamaps.Control.deselectNode(node);
|
Metamaps.Control.deselectNode(node);
|
||||||
} else {
|
} else {
|
||||||
Metamaps.Control.selectNode(node);
|
Metamaps.Control.selectNode(node,e);
|
||||||
}
|
}
|
||||||
//trigger animation to final styles
|
//trigger animation to final styles
|
||||||
Metamaps.Visualize.mGraph.fx.animate({
|
Metamaps.Visualize.mGraph.fx.animate({
|
||||||
|
|
|
@ -1637,13 +1637,16 @@ Metamaps.Control = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
selectNode: function (node) {
|
selectNode: function (node,e) {
|
||||||
if (Metamaps.Selected.Nodes.indexOf(node) != -1) return;
|
if (Metamaps.Selected.Nodes.indexOf(node) != -1) return;
|
||||||
node.selected = true;
|
node.selected = true;
|
||||||
node.setData('dim', 30, 'current');
|
node.setData('dim', 30, 'current');
|
||||||
node.eachAdjacency(function (adj) {
|
if(!(e.ctrlKey) && !(e.altKey)){
|
||||||
Metamaps.Control.selectEdge(adj);
|
node.eachAdjacency(function (adj) {
|
||||||
});
|
Metamaps.Control.selectEdge(adj);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Metamaps.Selected.Nodes.push(node);
|
Metamaps.Selected.Nodes.push(node);
|
||||||
},
|
},
|
||||||
deselectAllNodes: function () {
|
deselectAllNodes: function () {
|
||||||
|
@ -1656,9 +1659,11 @@ Metamaps.Control = {
|
||||||
},
|
},
|
||||||
deselectNode: function (node) {
|
deselectNode: function (node) {
|
||||||
delete node.selected;
|
delete node.selected;
|
||||||
|
/*
|
||||||
node.eachAdjacency(function (adj) {
|
node.eachAdjacency(function (adj) {
|
||||||
Metamaps.Control.deselectEdge(adj);
|
Metamaps.Control.deselectEdge(adj);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
node.setData('dim', 25, 'current');
|
node.setData('dim', 25, 'current');
|
||||||
|
|
||||||
//remove the node
|
//remove the node
|
||||||
|
|
Loading…
Reference in a new issue