fix selection box on radial view - fix #463
This commit is contained in:
parent
52cbd57367
commit
d778016571
1 changed files with 27 additions and 8 deletions
|
@ -1082,7 +1082,18 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
return 'nothing'; // case 4?
|
return 'nothing'; // case 4?
|
||||||
}, // handleSelectionBeforeDragging
|
}, // handleSelectionBeforeDragging
|
||||||
|
getNodeXY: function(node) {
|
||||||
|
if (typeof node.pos.x === "number" && typeof node.pos.y === "number") {
|
||||||
|
return node.pos
|
||||||
|
} else if (typeof node.pos.theta === "number" && typeof node.pos.rho === "number") {
|
||||||
|
return new $jit.Polar(node.pos.theta, node.pos.rho).getc(true)
|
||||||
|
} else {
|
||||||
|
console.error('getNodeXY: unrecognized node pos format')
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
selectWithBox: function (e) {
|
selectWithBox: function (e) {
|
||||||
|
var self = this
|
||||||
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,
|
||||||
|
@ -1094,11 +1105,17 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// select all nodes that are within the box
|
// select all nodes 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 pos = self.getNodeXY(n)
|
||||||
y = n.pos.y
|
var x = pos.x,
|
||||||
|
y = 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)) {
|
// depending on which way the person dragged the box, check that
|
||||||
|
// x and y are between the start and end values of the box
|
||||||
|
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 (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
if (n.selected) {
|
if (n.selected) {
|
||||||
Metamaps.Control.deselectNode(n)
|
Metamaps.Control.deselectNode(n)
|
||||||
|
@ -1123,10 +1140,12 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
edgesToToggle.forEach(function (edge) {
|
edgesToToggle.forEach(function (edge) {
|
||||||
var fromNodeX = edge.nodeFrom.pos.x
|
var fromNodePos = self.getNodeXY(edge.nodeFrom)
|
||||||
var fromNodeY = -1 * edge.nodeFrom.pos.y
|
var fromNodeX = fromNodePos.x
|
||||||
var toNodeX = edge.nodeTo.pos.x
|
var fromNodeY = -1 * fromNodePos.y
|
||||||
var toNodeY = -1 * edge.nodeTo.pos.y
|
var toNodePos = self.getNodeXY(edge.nodeTo)
|
||||||
|
var toNodeX = toNodePos.x
|
||||||
|
var toNodeY = -1 * toNodePos.y
|
||||||
|
|
||||||
var maxX = fromNodeX
|
var maxX = fromNodeX
|
||||||
var maxY = fromNodeY
|
var maxY = fromNodeY
|
||||||
|
|
Loading…
Reference in a new issue