Exemplo n.º 1
0
 def set_source_signal(self,widget):
     if self.osm:
         place=self.get_place()
         self.osm_box.remove(self.osm)
         self.osm.destroy()
     else:
         place=self.place_request
         self.place_request=None
     if '__version__' in dir(osmgpsmap) and osmgpsmap.__version__>='0.4.0':
         self.osm = osmgpsmap.GpsMap(
             tile_cache=os.path.join(settings.cache_dir,'maps/')+map_source[widget.get_active()][2],
             map_source=map_source[widget.get_active()][1],
         )
     else:
         self.osm = osmgpsmap.GpsMap(
             tile_cache=os.path.join(settings.cache_dir,'maps/')+map_source[widget.get_active()][2],
             tile_cache_is_full_path=True,
             repo_uri=map_source[widget.get_active()][1],
         )
     self.osm.connect('button-release-event', self.map_clicked)
     self.osm.connect('button-press-event', self.map_clicked)
     target_list=[('image-filename', gtk.TARGET_SAME_APP, 1)]
     self.osm.drag_dest_set(gtk.DEST_DEFAULT_ALL, target_list,
             gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY)
     self.osm.connect("drag-data-received",self.drag_receive_signal)
     self.osm_box.pack_start(self.osm)
     self.osm_box.show_all()
     if place:
         self.osm.set_mapcenter(*place) #todo: this causes an assertion - why?
         self.update_map_items()
Exemplo n.º 2
0
    def __init__(self, track, title, color, width, height, show_terrain):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_default_size(width, height)
        self.connect('destroy', lambda x: gtk.main_quit())
        self.vbox = gtk.VBox(False, 0)
        self.add(self.vbox)
        #        self.osm = osmgpsmap.GpsMap(repo_uri = "http://acetate.geoiq.com/tiles/acetate-hillshading/#Z/#X/#Y.png")
        if show_terrain:
            self.osm = osmgpsmap.GpsMap(
                repo_uri="http://khm.google.com/vt/lbw/lyrs=p&x=#X&y=#Y&z=#Z")
        else:
            self.osm = osmgpsmap.GpsMap(
                repo_uri="http://mt1.google.com/vt/lyrs=y&x=#X&y=#Y&z=#Z")


#        self.osm = osmgpsmap.GpsMap(repo_uri="http://tile.openstreetmap.org/#Z/#X/#Y.png")
        self.osm.layer_add(osmgpsmap.GpsMapOsd(show_dpad=True, show_zoom=True))
        self.osm.connect('button_release_event', self._map_clicked)
        #        self.osm.connect("motion_notify_event", self.update_distance)
        #connect keyboard shortcuts
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_FULLSCREEN,
                                       gtk.gdk.keyval_from_name("F11"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_UP,
                                       gtk.gdk.keyval_from_name("Up"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_DOWN,
                                       gtk.gdk.keyval_from_name("Down"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_LEFT,
                                       gtk.gdk.keyval_from_name("Left"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_RIGHT,
                                       gtk.gdk.keyval_from_name("Right"))
        self.vbox.pack_start(self.osm)
        self.status_bar = gtk.Statusbar()
        self.vbox.pack_start(self.status_bar, False, False, 0)
        #        gobject.timeout_add(500, self.updateDistance)
        # create the track
        map_track = osmgpsmap.GpsMapTrack()
        map_track.set_property("line-width", 2)
        map_track.set_property("color", gtk.gdk.color_parse(color))
        for i in range(0, len(track.trackpoints)):
            map_track.add_point(
                osmgpsmap.point_new_degrees(track.trackpoints.lats[i],
                                            track.trackpoints.lngs[i]))
        self.osm.track_add(map_track)
        # center the track
        (center_lat, lat_range) = track.get_mid_point_range("lats")
        (center_lng, lng_range) = track.get_mid_point_range("lngs")
        max_range = max(lat_range, lng_range)
        if max_range > 0.04: zoom = 14
        else: zoom = 15
        self.osm.set_center_and_zoom(latitude=center_lat,
                                     longitude=center_lng,
                                     zoom=zoom)
        # TODO: add numbers every 1/2 mile on the track. We'll need an image for each number to
        # do this
        #        pb = gtk.gdk.pixbuf_new_from_file_at_size (num + ".png", 24, 24)
        #        self.osm.image_add(lat, lon, pb)
        self.set_title(title)
Exemplo n.º 3
0
    def change_map(self, obj, map_type):
        if obj is not None:
            self.osm.layer_remove_all()
            self.osm.image_remove_all()
            self.vbox.remove(self.osm)
            self.osm.destroy()
        tiles_path = os.path.join(config.get('geography.path'),
                                  constants.tiles_path[map_type])
        if not os.path.isdir(tiles_path):
            try:
                os.makedirs(tiles_path, 0755)  # create dir like mkdir -p
            except:
                ErrorDialog(
                    _("Can't create tiles cache directory for '%s'.") %
                    constants.map_title[map_type])
        config.set("geography.map_service", map_type)
        self.current_map = map_type
        http_proxy = os.environ.get('http_proxy')
        if 0:
            self.osm = DummyMapNoGpsPoint()
        else:
            if http_proxy:
                self.osm = osmgpsmap.GpsMap(
                    tile_cache=tiles_path,
                    proxy_uri=http_proxy,
                    map_source=constants.map_type[map_type])
            else:
                self.osm = osmgpsmap.GpsMap(
                    tile_cache=tiles_path,
                    map_source=constants.map_type[map_type])
        current_map = osmgpsmap.GpsMapOsd(show_dpad=False, show_zoom=True)
        self.end_selection = None
        self.osm.layer_add(current_map)
        self.osm.layer_add(DummyLayer())
        self.selection_layer = self.add_selection_layer()
        self.cross_map = osmgpsmap.GpsMapOsd(show_crosshair=False)
        self.set_crosshair(config.get("geography.show_cross"))
        self.osm.set_center_and_zoom(config.get("geography.center-lat"),
                                     config.get("geography.center-lon"),
                                     config.get("geography.zoom"))

        self.osm.connect('button_release_event', self.map_clicked)
        self.osm.connect('button_press_event', self.map_clicked)
        self.osm.connect("motion-notify-event", self.motion_event)
        self.osm.connect('changed', self.zoom_changed)
        self.osm.show()
        self.vbox.pack_start(self.osm)
        if obj is not None:
            self._createmap(None)
Exemplo n.º 4
0
    def on_run(self):
        no_map = None
        if not self.is_active:
            pres_keys = sorted(self.plugin.config['presets'].keys())
            for key in pres_keys:
                self.preset_liststore.append((key, ))

        for name in self.plugin.config_default_values:
            if name == 'presets':
                continue
            if name == 'preview_provider':
                self.xml.get_object(name).set_active(self.plugin.config[name])
                continue
            widget = self.xml.get_object(name)
            widget.set_text(str(self.plugin.config[name]))

        try:
            import osmgpsmap
            if osmgpsmap.__version__ < '0.6':
                no_map = True
                log.debug('python-osmgpsmap < 0.6 detected')
        except:
            no_map = True
            log.debug('python-osmgpsmap not detected')

        log.debug('python-osmgpsmap > 0.5 detected')
        if not no_map and not self.is_active:
            from layers import DummyLayer

            vbox = self.xml.get_object('vbox1')
            vbox.set_size_request(400, -1)

            self.osm = osmgpsmap.GpsMap()
            self.osm.layer_add(
                osmgpsmap.GpsMapOsd(show_dpad=True, show_zoom=True))
            self.osm.layer_add(DummyLayer())
            lat = self.plugin.config['lat']
            lon = self.plugin.config['lon']
            if not self.is_valid_coord(lat, lon):
                self.lat = self.lon = 0.0
                self.xml.get_object('lat').set_text('0.0')
                self.xml.get_object('lon').set_text('0.0')
            self.osm.set_center_and_zoom(self.lat, self.lon, 12)
            self.path_to_image = os.path.abspath(
                gtkgui_helpers.get_icon_path('gajim', 16))
            self.icon = gtk.gdk.pixbuf_new_from_file_at_size(
                self.path_to_image, 16, 16)
            self.osm.connect('button_release_event', self.map_clicked)
            vbox.pack_start(self.osm, expand=True, fill=True, padding=6)
            label = gtk.Label(
                _('Click the right mouse button to specify the location, \n'
                  'middle mouse button to show / '
                  'hide the contacts on the map'))
            vbox.pack_start(label, expand=False, fill=False, padding=6)
            self.is_active = True
            self.images = []
            self.osm_image = self.osm.image_add(self.lat, self.lon, self.icon)
            self.xml.get_object('lat').connect('changed', self.on_lon_changed)
            self.xml.get_object('lon').connect('changed', self.on_lon_changed)
Exemplo n.º 5
0
    def load_map_clicked(self, button):
        uri = self.repouri_entry.get_text()
        format = self.image_format_entry.get_text()
        if uri and format:
            if self.osm:
                #remove old map
                self.vbox.remove(self.osm)
            try:
                self.osm = osmgpsmap.GpsMap(repo_uri=uri,
                                            image_format=format,
                                            proxy_uri=proxy_address)
            except Exception, e:
                print "ERROR:", e
                self.osm = osmgpsmap.GpsMap()

            self.vbox.pack_start(self.osm, True)
            self.osm.connect('button_release_event', self.map_clicked)
            self.osm.show()
Exemplo n.º 6
0
 def __init__(self):
     gtk.Builder.__init__(self)
     self.add_from_file(constants.GUI_BASE+'/micromappa_gui.glade')
     self.connect_signals(self)
     #Map
     self.map=osmgpsmap.GpsMap()
     self.get_object('mapbox').pack_start(self.map,True,True)
     #Data
     self.data=layerstore.LayerStore()
     self.layers_features=[]
     #Configure window
     self.get_object('window').set_title(__NAME__)
     self.get_object('window').show_all()
     self.get_object('window').maximize()
Exemplo n.º 7
0
    def __init__(self):
        self.trace_thread = None
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self.set_default_size(800, 600)
        self.old_height = 0
        self.connect("check-resize", self.on_window_resize)
        self.connect('destroy', lambda x: gtk.main_quit())
        self.set_title('PYTrace')

        if 0:
            self.osm = DummyMapNoGpsPoint()
        else:
            self.osm = osmgpsmap.GpsMap()
        self.osm.layer_add(osmgpsmap.GpsMapOsd(show_dpad=True, show_zoom=True))

        self.osm.connect('button_release_event', self.map_clicked)

        #connect keyboard shortcuts
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_FULLSCREEN,
                                       gtk.gdk.keyval_from_name("F11"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_UP,
                                       gtk.gdk.keyval_from_name("Up"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_DOWN,
                                       gtk.gdk.keyval_from_name("Down"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_LEFT,
                                       gtk.gdk.keyval_from_name("Left"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_RIGHT,
                                       gtk.gdk.keyval_from_name("Right"))

        #connect to tooltip
        self.show_tooltips = False
        self.osm.props.has_tooltip = True
        self.osm.connect("query-tooltip", self.on_query_tooltip)

        self.vbox = gtk.VBox(False, 0)
        self.add(self.vbox)

        self.vp = gtk.VPaned()
        self.vbox.pack_start(self.vp, True, True)

        self.vp.add1(self.osm)

        vb2 = gtk.VBox(False, 0)
        self.vp.add2(vb2)

        # begin control ui
        self.target_entry = gtk.Entry()
        self.target_entry.connect("activate", self.trace_initiated)

        self.tr_button = gtk.Button('Trace')
        self.tr_button.connect("clicked", self.trace_initiated)

        hbox = gtk.HBox(False, 0)
        hbox.pack_start(self.target_entry)
        hbox.pack_start(self.tr_button, False)
        vb2.pack_start(hbox, False)
        # end control ui

        self.tb = gtk.TextBuffer()
        self.tv = gtk.TextView()
        self.tv.set_buffer(self.tb)
        self.tv.set_property('editable', False)

        vb2.pack_start(self.tv, True, True)
Exemplo n.º 8
0
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self.set_default_size(500, 500)
        self.connect('destroy', lambda x: gtk.main_quit())
        self.set_title('OpenStreetMap GPS Mapper')

        self.vbox = gtk.VBox(False, 0)
        self.add(self.vbox)

        if 0:
            self.osm = DummyMapNoGpsPoint()
        else:
            self.osm = osmgpsmap.GpsMap(proxy_uri=proxy_address)
        self.osm.layer_add(osmgpsmap.GpsMapOsd(show_dpad=True, show_zoom=True))
        self.osm.layer_add(DummyLayer())

        self.osm.connect('button_release_event', self.map_clicked)

        #connect keyboard shortcuts
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_FULLSCREEN,
                                       gtk.gdk.keyval_from_name("F11"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_UP,
                                       gtk.gdk.keyval_from_name("Up"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_DOWN,
                                       gtk.gdk.keyval_from_name("Down"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_LEFT,
                                       gtk.gdk.keyval_from_name("Left"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_RIGHT,
                                       gtk.gdk.keyval_from_name("Right"))

        #connect to tooltip
        self.osm.props.has_tooltip = True
        self.osm.connect("query-tooltip", self.on_query_tooltip)

        self.latlon_entry = gtk.Entry()

        zoom_in_button = gtk.Button(stock=gtk.STOCK_ZOOM_IN)
        zoom_in_button.connect('clicked', self.zoom_in_clicked)
        zoom_out_button = gtk.Button(stock=gtk.STOCK_ZOOM_OUT)
        zoom_out_button.connect('clicked', self.zoom_out_clicked)
        home_button = gtk.Button(stock=gtk.STOCK_HOME)
        home_button.connect('clicked', self.home_clicked)
        cache_button = gtk.Button('Cache')
        cache_button.connect('clicked', self.cache_clicked)

        self.vbox.pack_start(self.osm)
        hbox = gtk.HBox(False, 0)
        hbox.pack_start(zoom_in_button)
        hbox.pack_start(zoom_out_button)
        hbox.pack_start(home_button)
        hbox.pack_start(cache_button)

        #add ability to test custom map URIs
        ex = gtk.Expander("<b>Map Repository URI</b>")
        ex.props.use_markup = True
        vb = gtk.VBox()
        self.repouri_entry = gtk.Entry()
        self.repouri_entry.set_text(self.osm.props.repo_uri)
        self.image_format_entry = gtk.Entry()
        self.image_format_entry.set_text(self.osm.props.image_format)

        lbl = gtk.Label("""
Enter an repository URL to fetch map tiles from in the box below. Special metacharacters may be included in this url

<i>Metacharacters:</i>
\t#X\tMax X location
\t#Y\tMax Y location
\t#Z\tMap zoom (0 = min zoom, fully zoomed out)
\t#S\tInverse zoom (max-zoom - #Z)
\t#Q\tQuadtree encoded tile (qrts)
\t#W\tQuadtree encoded tile (1234)
\t#U\tEncoding not implemeted
\t#R\tRandom integer, 0-4""")
        lbl.props.xalign = 0
        lbl.props.use_markup = True
        lbl.props.wrap = True

        ex.add(vb)
        vb.pack_start(lbl, False)

        hb = gtk.HBox()
        hb.pack_start(gtk.Label("URI: "), False)
        hb.pack_start(self.repouri_entry, True)
        vb.pack_start(hb, False)

        hb = gtk.HBox()
        hb.pack_start(gtk.Label("Image Format: "), False)
        hb.pack_start(self.image_format_entry, True)
        vb.pack_start(hb, False)

        gobtn = gtk.Button("Load Map URI")
        gobtn.connect("clicked", self.load_map_clicked)
        vb.pack_start(gobtn, False)

        self.show_tooltips = False
        cb = gtk.CheckButton("Show Location in Tooltips")
        cb.props.active = self.show_tooltips
        cb.connect("toggled", self.on_show_tooltips_toggled)
        self.vbox.pack_end(cb, False)

        cb = gtk.CheckButton("Disable Cache")
        cb.props.active = False
        cb.connect("toggled", self.disable_cache_toggled)
        self.vbox.pack_end(cb, False)

        myhb = gtk.HBox(False, 0)
        trb = gtk.Button("Show Trace")
        trb.connect("clicked", self.show_trace_on_map)
        myhb.pack_end(trb, False)
        self.day_entry = gtk.Entry()
        self.day_entry.set_text("1")
        self.sim_entry = gtk.Entry()
        self.sim_entry.set_text("7760964401")
        myhb.pack_start(self.sim_entry, False)
        myhb.pack_start(self.day_entry, False)
        self.vbox.pack_end(myhb, False)

        self.vbox.pack_end(ex, False)
        self.vbox.pack_end(self.latlon_entry, False)
        self.vbox.pack_end(hbox, False)

        gobject.timeout_add(500, self.print_tiles)
Exemplo n.º 9
0
Arquivo: map.py Projeto: MorS25/wasp
    def update_state_from_config(self):
        self._cachebase = self.config_get("cache", self.DEFAULT_CACHE)
        self._proxy = self.config_get("proxy", self.DEFAULT_PROXY)
        self._source = self.config_get("source", self.DEFAULT_SOURCE)

        #convert "" -> None
        if self._proxy == "":
            self._proxy = None
        if self._cachebase == "":
            self._cachebase = None
        else:
            if not os.path.isdir(self._cachebase):
                os.makedirs(self._cachebase)

        if not self._map:
            if MAP_AVAILABLE:
                kwargs = {
                    "map_source": int(self._source),
                    "proxy_uri": self._proxy,
                    "tile_cache_base": self._cachebase
                }
                if MAP_NEW_API:
                    kwargs["tile_cache"] = osmgpsmap.CACHE_FRIENDLY

                self._map = osmgpsmap.GpsMap(**kwargs)

                #add OSD
                if MAP_NEW_API:
                    self._map.layer_add(osmgpsmap.GpsMapOsd(show_zoom=True))

                #minimum size of one tile
                self._map.set_size_request(-1, 256)

                LOG.info("Map %s URI: %s" %
                         (self._source, self._map.props.repo_uri))
                LOG.info("Proxy: %s" % self._map.props.proxy_uri)
                LOG.info("Cache: %s" % self._map.props.tile_cache)

                while True:
                    try:
                        signal, (func, args) = self._cbs.popitem()
                        self._map.connect(signal, func, *args)
                    except KeyError:
                        break

                self._flightplan.set_map(self._map)

                #generate notify events to keep the groundstation ui in sync
                self._map.props.auto_center = self._map.props.auto_center
                self._map.props.show_trip_history = self._map.props.show_trip_history

                self._map.connect('changed', self._on_map_changed)
                self._map.connect('size-allocate', self._on_map_size_allocate)
                self._map.connect_after('button-press-event',
                                        self._on_map_button_press)

            else:
                self._map = gtk.Label("Map Disabled")

            self._pane.pack1(self._map, resize=True, shrink=False)
            self._pane.pack2(self._alt, resize=False, shrink=False)
            self._pane.set_position(1000)
Exemplo n.º 10
0
    def __init__(self):
        self.btsmapperWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.btsmapperWindow.set_resizable(True)  # Allow window resizing
        self.btsmapperWindow.set_title(
            "Python BTS Mapper - Free-knowledge")  # Title of the window
        #self.btsmapperWindow.set_decorated(False)  # Hide the edges of the window
        self.btsmapperWindow.set_icon_from_file(
            "%s/images/icone.png" % BTSMAPPER_PATH)  # Specify an icon
        self.btsmapperWindow.set_position(
            gtk.WIN_POS_CENTER)  # Center window at launch
        self.btsmapperWindow.set_border_width(10)  # Width of the inside edge
        self.btsmapperWindow.set_size_request(1000, 500)  # Size of the window
        self.btsmapperWindow.connect("delete_event",
                                     self.quit_dialog)  # Quit message dialog
        self.btsmapperWindow.connect(
            'key-press-event', lambda o, event: event.keyval == gtk.keysyms.F11
            and self.toggle_fullscreen())
        self.btsmapperWindow.show()

        self.fullscreen = 0

        self.vbox = gtk.VBox(False, 0)
        self.btsmapperWindow.add(self.vbox)

        self.hbox = gtk.HBox(True, 0)
        self.vbox.pack_start(self.hbox)

        self.vterm = vte.Terminal()
        self.vterm.set_scrollback_lines(-1)
        self.vterm.allow_bold = True
        self.vterm.audible_bell = True
        self.foreground = gtk.gdk.color_parse('#FFFFFF')
        self.background = gtk.gdk.color_parse('#000000')
        self.vterm.set_color_foreground(self.foreground)
        self.vterm.set_color_background(self.background)
        # self.vterm.background_image_file = "%s/images/logo.png" % BTSMAPPER_PATH
        # self.vterm.connect("child-exited", lambda term: gtk.main_quit())

        self.hbox.pack_start(self.vterm)

        if 0:
            self.osm = DummyMapNoGpsPoint()
        else:
            self.osm = osmgpsmap.GpsMap()
        self.osm.layer_add(osmgpsmap.GpsMapOsd(show_dpad=True, show_zoom=True))
        self.osm.layer_add(DummyLayer())

        self.osm.connect('button_release_event', self.map_clicked)

        #connect keyboard shortcuts
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_FULLSCREEN,
                                       gtk.gdk.keyval_from_name("F11"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_UP,
                                       gtk.gdk.keyval_from_name("Up"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_DOWN,
                                       gtk.gdk.keyval_from_name("Down"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_LEFT,
                                       gtk.gdk.keyval_from_name("Left"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_RIGHT,
                                       gtk.gdk.keyval_from_name("Right"))

        self.hbox.pack_start(self.osm)

        gobject.timeout_add(500, self.print_tiles)
        self.osm.set_center_and_zoom(46.227638, 2.213749,
                                     5)  # Centrer sur la France

        ex = gtk.Expander("<b>History</b>")
        ex.set_expanded(True)
        ex.props.use_markup = True

        vb = gtk.VBox()
        ex.add(vb)

        self.debug_button = gtk.Button("Start geolocation")
        self.debug_button.connect(
            'clicked',
            lambda e: thread.start_new_thread(self.debug_clicked, ()))

        hbox = gtk.HBox(True, 0)

        # self.liststore_geoloc
        self.liststore_geoloc = gtk.ListStore(str, str, str, str, str, str,
                                              str, str)
        # scrollbar_sortie_geoloc
        scrolled_sortie_geoloc = gtk.ScrolledWindow()
        hbox.pack_start(scrolled_sortie_geoloc, True, True, 0)
        scrolled_sortie_geoloc.show()
        # self.treeasview_sortie_geoloc
        self.treeview_sortie_geoloc = gtk.TreeView(self.liststore_geoloc)
        self.treeview_sortie_geoloc.set_rules_hint(True)
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Discovered", gtk.CellRendererText(), text=0))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Telecoms company",
                               gtk.CellRendererText(),
                               text=1))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Latitude", gtk.CellRendererText(), text=2))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Longitude", gtk.CellRendererText(), text=3))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Cell Identity", gtk.CellRendererText(),
                               text=4))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Mobile Country Code",
                               gtk.CellRendererText(),
                               text=5))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Mobile Network Code",
                               gtk.CellRendererText(),
                               text=6))
        self.treeview_sortie_geoloc.append_column(
            gtk.TreeViewColumn("Location Area Code",
                               gtk.CellRendererText(),
                               text=7))
        self.treeview_sortie_geoloc.set_headers_visible(True)
        self.treeview_sortie_geoloc.connect("cursor-changed", self.loc_history)
        scrolled_sortie_geoloc.add(self.treeview_sortie_geoloc)
        scrolled_sortie_geoloc.set_policy(gtk.POLICY_AUTOMATIC,
                                          gtk.POLICY_AUTOMATIC)
        self.treeview_sortie_geoloc.show()

        vb.pack_start(hbox, True)

        self.vbox.pack_start(ex, False, True, 0)

        hbox.show()
        vb.show()
        ex.show()

        # boite2_geoloc
        boite2_geoloc = gtk.HBox(False, 5)
        self.vbox.pack_start(boite2_geoloc, False, False, 0)
        boite2_geoloc.show()

        # self.btn_geoloc
        self.btn_geoloc = gtk.Button("Monitor broadcast messages")
        self.btn_geoloc.set_size_request(
            int(self.btn_geoloc.size_request()[0] * 1.2),
            self.btn_geoloc.size_request()[1])
        # self.btn_geoloc.connect('clicked', lambda e: thread.start_new_thread(self.geoloc, ()))
        self.btn_geoloc.connect(
            'clicked',
            lambda e: thread.start_new_thread(self.debug_clicked, ()))
        boite2_geoloc.pack_start(self.btn_geoloc, True, True, 0)
        self.btn_geoloc.show()

        # self.btn2_geoloc
        self.btn2_geoloc = gtk.Button("kill gammu")
        self.btn2_geoloc.set_size_request(
            int(self.btn2_geoloc.size_request()[0] * 1.2),
            self.btn2_geoloc.size_request()[1])
        self.statuGeolocLoop = False
        # self.btn2_geoloc.connect('clicked', lambda e: thread.start_new_thread(self.geolocLoop, ()))
        self.btn2_geoloc.connect('clicked', lambda e: self.killall_gammu())
        boite2_geoloc.pack_start(self.btn2_geoloc, False, False, 0)
        self.btn2_geoloc.show()
Exemplo n.º 11
0
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        db.get_stations()
        self.set_default_size(900, 675)
        self.connect('destroy', lambda x: gtk.main_quit())
        self.set_title('OpenStreetMap GPS Mapper')

        self.vbox = gtk.VBox(False, 0)
        self.add(self.vbox)

        if 0:
            self.osm = DummyMapNoGpsPoint()
        else:
            self.osm = osmgpsmap.GpsMap()
        #self.osm.layer_add(
        #            osmgpsmap.GpsMapOsd(
        #                show_dpad=True,
        #                show_zoom=True))
        self.osm.layer_add(DummyLayer())

        self.osm.connect('button_release_event', self.map_clicked)

        #connect keyboard shortcuts
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_FULLSCREEN,
                                       gtk.gdk.keyval_from_name("F11"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_UP,
                                       gtk.gdk.keyval_from_name("Up"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_DOWN,
                                       gtk.gdk.keyval_from_name("Down"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_LEFT,
                                       gtk.gdk.keyval_from_name("Left"))
        self.osm.set_keyboard_shortcut(osmgpsmap.KEY_RIGHT,
                                       gtk.gdk.keyval_from_name("Right"))

        #connect to tooltip
        self.osm.props.has_tooltip = True
        self.osm.connect("query-tooltip", self.on_query_tooltip)

        self.osm.set_center_and_zoom(55.872, -4.291, 16)

        self.latlon_entry = gtk.Entry()

        zoom_in_button = gtk.Button(stock=gtk.STOCK_ZOOM_IN)
        zoom_in_button.connect('clicked', self.zoom_in_clicked)
        zoom_out_button = gtk.Button(stock=gtk.STOCK_ZOOM_OUT)
        zoom_out_button.connect('clicked', self.zoom_out_clicked)
        home_button = gtk.Button(stock=gtk.STOCK_HOME)
        home_button.connect('clicked', self.home_clicked)
        cache_button = gtk.Button('Cache')
        cache_button.connect('clicked', self.cache_clicked)

        hbox2 = gtk.HBox(False, 0)

        # liststore for stations
        lstore = gtk.ListStore(str, int)
        s = db.get_stations()
        for i in s:
            lstore.append([i[0], i[1]])
        treeview = gtk.TreeView(lstore)
        rendererText = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Station", rendererText, text=0)
        column.set_sort_column_id(0)
        column.set_min_width(100)
        treeview.append_column(column)

        column = gtk.TreeViewColumn("Points", rendererText, text=1)
        column.set_sort_column_id(1)
        column.set_min_width(50)
        treeview.append_column(column)

        treeview.columns_autosize()
        treeview.connect("row-activated", self.on_activated)

        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(treeview)
        sw.set_size_request(200, -1)

        vbox2 = gtk.VBox(False, 0)

        calendar = gtk.Calendar()
        vbox2.pack_start(calendar, False)
        vbox2.pack_start(sw)

        hbox2.pack_start(vbox2, expand=False)
        hbox2.pack_start(self.osm)
        self.vbox.pack_start(hbox2)

        hbox = gtk.HBox(False, 0)
        hbox.pack_start(zoom_in_button)
        hbox.pack_start(zoom_out_button)
        hbox.pack_start(home_button)
        hbox.pack_start(cache_button)

        #add ability to test custom map URIs
        ex = gtk.Expander("<b>Map Repository URI</b>")
        ex.props.use_markup = True
        vb = gtk.VBox()
        self.repouri_entry = gtk.Entry()
        self.repouri_entry.set_text(self.osm.props.repo_uri)
        self.image_format_entry = gtk.Entry()
        self.image_format_entry.set_text(self.osm.props.image_format)

        lbl = gtk.Label("""
Enter an repository URL to fetch map tiles from in the box below. Special metacharacters may be included in this url

<i>Metacharacters:</i>
\t#X\tMax X location
\t#Y\tMax Y location
\t#Z\tMap zoom (0 = min zoom, fully zoomed out)
\t#S\tInverse zoom (max-zoom - #Z)
\t#Q\tQuadtree encoded tile (qrts)
\t#W\tQuadtree encoded tile (1234)
\t#U\tEncoding not implemeted
\t#R\tRandom integer, 0-4""")
        lbl.props.xalign = 0
        lbl.props.use_markup = True
        lbl.props.wrap = True

        ex.add(vb)
        vb.pack_start(lbl, False)

        hb = gtk.HBox()
        hb.pack_start(gtk.Label("URI: "), False)
        hb.pack_start(self.repouri_entry, True)
        vb.pack_start(hb, False)

        hb = gtk.HBox()
        hb.pack_start(gtk.Label("Image Format: "), False)
        hb.pack_start(self.image_format_entry, True)
        vb.pack_start(hb, False)

        gobtn = gtk.Button("Load Map URI")
        gobtn.connect("clicked", self.load_map_clicked)
        vb.pack_start(gobtn, False)

        self.show_tooltips = False
        cb = gtk.CheckButton("Show Location in Tooltips")
        cb.props.active = self.show_tooltips
        cb.connect("toggled", self.on_show_tooltips_toggled)
        self.vbox.pack_end(cb, False)

        cb = gtk.CheckButton("Disable Cache")
        cb.props.active = False
        cb.connect("toggled", self.disable_cache_toggled)
        self.vbox.pack_end(cb, False)

        self.vbox.pack_end(ex, False)
        self.vbox.pack_end(self.latlon_entry, False)
        self.vbox.pack_end(hbox, False)

        gobject.timeout_add(500, self.print_tiles)