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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/fgmapping/context_menu.rb', line 16
def (contextEvent)
dlg=contextEvent.widget.parent.parent
entries=["Set Waypoint", "Delete Waypoint", "Waypoints to Route-Mgr", "Set Origin", "-", "Save Waypoints", "Save Track", "Load Waypoints",
"Load Track", ["Metric Units", dlg.metricUnit]]
=Qt::Menu.new
entries.each{|e|
if e.kind_of? Array then
action = Qt::Action.new(e[0], nil)
action.setCheckable(true)
action.setChecked(e[1])
.addAction(action)
else
if e=="-" then
.addSeparator
else
action = Qt::Action.new(e, nil)
if e =~ /(Delete Waypoint|Waypoints to)/ then
action.setEnabled(false) if dlg.waypoints.nodes.empty?
end
.addAction(action)
end
end
}
sel=.exec(contextEvent.screenPos)
sel=sel.text if !sel.nil?
lon=dlg.node.tolon(dlg.node.xtile + contextEvent.scenePos.x / 256.0)
lat=dlg.node.tolat(dlg.node.ytile + contextEvent.scenePos.y / 256.0)
case sel
when entries[0]
i=dlg.waypoints << Node.new(nil, Time.now, lon, lat)
dlg.putflag(contextEvent.scenePos.x, contextEvent.scenePos.y, i, dlg.waypoints.nodes.last)
if i==1 and dlg.waypoints.nodes.length == 1 then
dlg.w.lBcurrentwp.text="1"
dlg.waypoints.currentwp=1
end
when entries[1]
d=dlg.waypoints.del(lon,lat)
if dlg.w.lBcurrentwp.text.to_i == d then
dlg.w.lBcurrentwp.text="-"
end
dlg.movemap(dlg.node, true)
when entries[2]
Thread.new {
dlg.waypoints.nodes.each do |n|
dlg.writeFlightsim("set /autopilot/route-manager/input @INSERT-1:#{n.lon.to_s.gsub(",",".")},#{n.lat.to_s.gsub(",",".")}")
end
}
when entries[3]
dlg.node = Node.new(1, Time.now, lon, lat)
dlg.offset_x = 0
dlg.offset_y = 0
dlg.movemap(dlg.node, true)
when entries[5]
dlg.saveWaypoints([dlg.waypoints])
when entries[6]
dlg.savetrack(dlg.mytracks)
when entries[7]
savecurrent = dlg.waypoints.currentwp
if dlg.loadwaypoint("Load Waypoints") then
dlg.waypoints.currentwp = nil
else
dlg.waypoints.currentwp = savecurrent
end
when entries[8]
dlg.mytrack_current += (dlg.w.pBrecordTrack.isChecked ? 0 : 1)
savewp=dlg.mytracks[dlg.mytrack_current]
if dlg.mytracks[dlg.mytrack_current].nil? then
dlg.mytracks[dlg.mytrack_current] = Way.new(1, 'user', Time.now, dlg.nextcolor)
@prev_track_node = nil
end
if dlg.loadtrack("Load Track") then
dlg.w.pBrecordTrack.text = "Record Track #{dlg.mytrack_current + 2}"
dlg.w.pBrecordTrack.setChecked(false)
else
dlg.mytracks[dlg.mytrack_current]=savewp
end
when entries[9][0]
dlg.metricUnit = !dlg.metricUnit
end end
|