Exemplo n.º 1
0
    def on_menu(self, event):
        '''handle menu selection'''
        state = self.state
        # see if it is a popup menu
        if state.popup_object is not None:
            obj = state.popup_object
            ret = obj.popup_menu.find_selected(event)
            if ret is not None:
                ret.call_handler()
                state.event_queue.put(
                    SlipMenuEvent(state.popup_latlon, event, [
                        SlipObjectSelection(obj.key, 0, obj.layer,
                                            obj.selection_info())
                    ], ret))
                state.popup_object = None
                state.popup_latlon = None
        if state.default_popup is not None:
            ret = state.default_popup.popup.find_selected(event)
            if ret is not None:
                ret.call_handler()
                state.event_queue.put(
                    SlipMenuEvent(state.popup_latlon, event, [], ret))

        # otherwise a normal menu
        ret = self.menu.find_selected(event)
        if ret is None:
            return
        ret.call_handler()
        if ret.returnkey == 'toggleGrid':
            state.grid = ret.IsChecked()
        elif ret.returnkey == 'toggleLegend':
            state.legend = ret.IsChecked()
        elif ret.returnkey == 'toggleFollow':
            state.follow = ret.IsChecked()
        elif ret.returnkey == 'toggleDownload':
            state.download = ret.IsChecked()
        elif ret.returnkey == 'setService':
            state.mt.set_service(ret.get_choice())
        elif ret.returnkey == 'gotoPosition':
            state.panel.enter_position()
        elif ret.returnkey == 'increaseBrightness':
            state.brightness += 20
            if state.brightness > 255:
                state.brightness = 255
        elif ret.returnkey == 'decreaseBrightness':
            state.brightness -= 20
            if state.brightness < -255:
                state.brightness = -255
        elif ret.returnkey == 'zoomIn':
            state.panel.change_zoom(1.0 / 1.2)
        elif ret.returnkey == 'zoomOut':
            state.panel.change_zoom(1.2)
        state.need_redraw = True
Exemplo n.º 2
0
 def selected_objects(self, pos):
     '''return a list of matching objects for a position'''
     state = self.state
     selected = []
     (px, py) = pos
     for layer in state.layers:
         for key in state.layers[layer]:
             obj = state.layers[layer][key]
             distance = obj.clicked(px, py)
             if distance is not None:
                 selected.append(SlipObjectSelection(key, distance, layer, extra_info=obj.selection_info()))
     selected.sort(key=lambda c: c.distance)
     return selected