blob: 8fe4fffa73fda733776ba7bdb563b1cf9bfab507 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// This tool lets you define a very simple line between two points.
// It is used by the BlueprintScaler to specify a sample distance to scale.
var LineTool = MapTool.extend(function(base){
var exports = {}
var selected_point = null
var line = exports.line = []
var can_drag, dragging
exports.down = function(e, cursor){
// rightclick?
if (e.ctrlKey || e.which === 3) {
cursor.quantize(1/map.zoom)
app.router.blueprintView.map.center.a = cursor.x.a
app.router.blueprintView.map.center.b = -cursor.y.a
cursor.x.b = cursor.x.a
cursor.y.b = cursor.y.a
return
}
this.cursor = cursor
switch (line.length) {
case 0:
line[0] = cursor.x_component()
can_drag = true
break
case 1:
line[1] = cursor.x_component()
can_drag = false
break
case 2:
line[0] = cursor.x_component()
line.pop()
can_drag = true
break
}
}
exports.move = function(e, cursor){
this.cursor = cursor
}
exports.drag = function(e, cursor){
if (dragging) {
line[1].a = cursor.x.b
line[1].b = cursor.y.b
}
else if (can_drag && cursor.magnitude() > 10/map.zoom) {
line[1] = cursor.y_component()
dragging = true
}
}
exports.up = function(e, cursor){
can_drag = dragging = false
}
return exports
})
|