Geography : gtk3 migration. several corrections.

svn: r20286
This commit is contained in:
Serge Noiraud 2012-08-29 22:13:09 +00:00
parent e1a53fe353
commit 232e76520e
2 changed files with 36 additions and 29 deletions

View File

@ -32,6 +32,7 @@ import os
import re import re
from gi.repository import GObject from gi.repository import GObject
import time import time
from math import pi
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -294,6 +295,7 @@ class GeoGraphyView(OsmGps, NavigationView):
changemapitem.show() changemapitem.show()
changemapitem.connect("activate", self.change_map, map) changemapitem.connect("activate", self.change_map, map)
changemap.append(changemapitem) changemap.append(changemapitem)
menu.show()
menu.popup(None, None, None, None, 0, event.time) menu.popup(None, None, None, None, 0, event.time)
return 1 return 1
@ -529,9 +531,12 @@ class GeoGraphyView(OsmGps, NavigationView):
""" """
Is this marker in the visible area ? Is this marker in the visible area ?
""" """
return True #return True
# BUG here : how to replace that ? # BUG here : how to replace that ?
bbox = self.osm.get_bbox() pt1 = osmgpsmap.MapPoint.new_degrees(0.0, 0.0)
pt2 = osmgpsmap.MapPoint.new_degrees(0.0, 0.0)
bbox = self.osm.get_bbox(pt1,pt2)
print bbox
s_lon = lon + 10.0 s_lon = lon + 10.0
s_lat = lat + 10.0 s_lat = lat + 10.0
s_bbox_lat1 = bbox[0] + 10.0 s_bbox_lat1 = bbox[0] + 10.0
@ -582,14 +587,12 @@ class GeoGraphyView(OsmGps, NavigationView):
""" """
level_start = self.osm.props.zoom level_start = self.osm.props.zoom
# BUG here : how to replace that ? # BUG here : how to replace that ?
#p1lat = p1lon = 0.0 #p1lat, p1lon = self.begin_selection.get_degrees()
#p1lat, p1lon = self.begin_selection.get_degrees(p1lat, p1lon) #p2lat, p2lon = self.end_selection.get_degrees()
#print p1lat, p1lon p1lat = 180 * self.begin_selection.rlat / pi
#p2lat, p2lon = self.end_selection.get_degrees(0.0, 0.0) p1lon = 180 * self.begin_selection.rlon / pi
p1lat = self.begin_selection.rlat p2lat = 180 * self.end_selection.rlat / pi
p1lon = self.begin_selection.rlon p2lon = 180 * self.end_selection.rlon / pi
p2lat = self.end_selection.rlat
p2lon = self.end_selection.rlon
lat = p1lat + ( p2lat - p1lat ) / 2 lat = p1lat + ( p2lat - p1lat ) / 2
lon = p1lon + ( p2lon - p1lon ) / 2 lon = p1lon + ( p2lon - p1lon ) / 2
# We center the map on the center of the region # We center the map on the center of the region

View File

@ -28,6 +28,7 @@
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os import os
from math import pi
from gi.repository import GObject from gi.repository import GObject
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -247,14 +248,11 @@ class OsmGps():
""" """
Moving during selection Moving during selection
""" """
# BUG here : how to replace that ? current = osmmap.convert_screen_to_geographic(int(event.x), int(event.y))
#current = osmgpsmap.MapPoint.new_degrees(0.0, 0.0)
current = osmgpsmap.MapPoint.new_degrees(int(event.x), int(event.y))
# BUG here : how to replace that ?
#osmmap.convert_screen_to_geographic(int(event.x), int(event.y), current)
#lat, lon = current.get_degrees() #lat, lon = current.get_degrees()
lat = current.rlat lat = 180 * current.rlat / pi
lon = current.rlon lon = 180 * current.rlon / pi
print event.x, event.y, lat, lon
if self.zone_selection: if self.zone_selection:
# We draw a rectangle to show the selected region. # We draw a rectangle to show the selected region.
layer = self.get_selection_layer() layer = self.get_selection_layer()
@ -308,18 +306,13 @@ class OsmGps():
mouse button 2 : begin zone selection mouse button 2 : begin zone selection
mouse button 3 : call the menu mouse button 3 : call the menu
""" """
# BUG here : how to replace that ?
#lat, lon = self.osm.get_event_location(event).get_degrees() #lat, lon = self.osm.get_event_location(event).get_degrees()
lat = self.osm.get_event_location(event).rlat lat = 180 * self.osm.get_event_location(event).rlat / pi
lon = self.osm.get_event_location(event).rlon lon = 180 * self.osm.get_event_location(event).rlon / pi
current = osmgpsmap.MapPoint.new_degrees(0.0, 0.0)
# BUG here : how to replace that ?
#osm.convert_screen_to_geographic(int(event.x), int(event.y), current)
current = osm.convert_screen_to_geographic(int(event.x), int(event.y)) current = osm.convert_screen_to_geographic(int(event.x), int(event.y))
# BUG here : how to replace that ?
#lat, lon = current.get_degrees() #lat, lon = current.get_degrees()
lat = current.rlat lat = 180 * current.rlat / pi
lon = current.rlon lon = 180 * current.rlon / pi
if event.button == 1: if event.button == 1:
if self.end_selection is not None: if self.end_selection is not None:
self.activate_selection_zoom(osm, event) self.activate_selection_zoom(osm, event)
@ -334,8 +327,19 @@ class OsmGps():
elif event.button == 2 and event.type == Gdk.EventType.BUTTON_RELEASE: elif event.button == 2 and event.type == Gdk.EventType.BUTTON_RELEASE:
self.end_selection = current self.end_selection = current
self.zone_selection = False self.zone_selection = False
elif event.button == 3: elif event.button == 3 and event.type == Gdk.EventType.BUTTON_PRESS:
self.build_nav_menu(osm, event, lat, lon ) # I don't see the menu. Why ?
#self.build_nav_menu(osm, event, lat, lon )
menu = Gtk.Menu()
menu.set_title(_('Map Menu'))
add_item = Gtk.MenuItem(label="title")
add_item.connect("activate", self.config_crosshair, event, lat , lon)
add_item.show()
menu.append(add_item)
menu.show()
menu.popup(None, None, None, None, event.button, event.time)
return 1
else: else:
self.save_center(lat, lon) self.save_center(lat, lon)
@ -405,7 +409,7 @@ class OsmGps():
Show or hide the crosshair ? Show or hide the crosshair ?
""" """
if active: if active:
self.cross_map = osmgpsmap.GpsMapOsd( show_crosshair=True) self.cross_map = osmgpsmap.MapOsd( show_crosshair=True)
self.osm.layer_add( self.cross_map ) self.osm.layer_add( self.cross_map )
# The two following are to force the map to update # The two following are to force the map to update
self.osm.zoom_in() self.osm.zoom_in()