Class: TileGraphicsItemGroup

Inherits:
Qt::GraphicsItemGroup
  • Object
show all
Defined in:
lib/main-dlg-impl.rb

Instance Method Summary collapse

Instance Method Details

#contextMenuEvent(contextEvent) ⇒ Object



1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
# File 'lib/main-dlg-impl.rb', line 1217

def contextMenuEvent(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]]
	menu=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])
			menu.addAction(action)
		else
			if e=="-" then
				menu.addSeparator
			else
				action = Qt::Action.new(e, nil)
				if e =~ /(Delete Waypoint|Waypoints to)/ then
					action.setEnabled(false) if dlg.waypoints.nodes.empty?
				end
				menu.addAction(action)
			end
		end
	}
	sel=menu.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 #case
end

#mousePressEvent(mouseEvent) ⇒ Object



1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
# File 'lib/main-dlg-impl.rb', line 1204

def mousePressEvent(mouseEvent)
	pos = mouseEvent.scenePos
	dlg=mouseEvent.widget.parent.parent
	case mouseEvent.button
		when Qt::LeftButton
			dlg.offset_x = pos.x / 256.0
			dlg.offset_y = pos.y / 256.0
			dlg.movemap(dlg.node)
#			when Qt::RightButton
		
	end # case
end