def create_map_controller(self): """ A scatter object to manipulate motor movement""" map_controller = Scatter( size_hint = (1,1), do_rotation=False, do_translation=True, do_scale=True,auto_bring_to_front = False) map_controller.center = Window.center # automatically determine the size based on screen size default_scale = Window.height / map_controller.height*1 # determine the size of active area map_controller.scale = default_scale # determine the amount of zoom and drag needed before moving map_controller.scale_max = default_scale*1.2 map_controller.scale_min = default_scale*0.8 # dummy object showing active area if debug_mode is True: map_controller.add_widget(Image()) def map_control_feedback(instance, value): """the callback functions for map_controller scatter object""" if debug_mode is True: if map_controller.center[0] - Window.center[0] > self.drag_x_sensitive: print('moving x+') elif map_controller.center[0] - Window.center[0] < -1* self.drag_x_sensitive: print('moving x-') elif map_controller.center[1] - Window.center[1] > self.drag_y_sensitive: print('moving y+') elif map_controller.center[1] - Window.center[1] < -1* self.drag_y_sensitive: print('moving y-') elif map_controller.scale < default_scale*0.9: print('pinch -') elif map_controller.scale > default_scale*1.1: print('pinch +') elif debug_mode is False: if map_controller.center[0] - Window.center[0] > self.drag_x_sensitive: mc.stage_library('move_x', '-') elif map_controller.center[0] - Window.center[0] < -1* self.drag_x_sensitive: mc.stage_library('move_x', '+') elif map_controller.center[1] - Window.center[1] > self.drag_y_sensitive: mc.stage_library('move_y', '-') elif map_controller.center[1] - Window.center[1] < -1*self.drag_y_sensitive: mc.stage_library('move_y', '+') elif map_controller.scale < default_scale*0.9: mc.camera_library('zoom_out') elif map_controller.scale > default_scale*1.1: mc.camera_library('zoom_in') #after taking actions, reset scatter location and scale to default map_controller.center = Window.center map_controller.scale = default_scale map_controller.bind(on_touch_up = map_control_feedback) return map_controller
def create_map_controller(): map_controller = Scatter( size_hint = (1,1), do_rotation=False, do_translation=True, do_scale=True, scale = 1, center = Window.center) # automatically determine the size based on screen size default_scale = Window.height / map_controller.height*0.75 # determine the size of active area map_controller.scale = default_scale # determine the amount of zoom and drag needed before moving map_controller.scale_max = default_scale*1.2 map_controller.scale_min = default_scale*0.8 x_sensitive = Window.width*0.3 y_sensitive = Window.height*0.3 # dummy object showing active area map_controller.add_widget(Image()) def map_control_feedback(instance, value): """the callback functions for map_controller scatter object""" if map_controller.center[0] - Window.center[0] > x_sensitive: #microscope_control.drag_right() print('moving x+') elif map_controller.center[0] - Window.center[0] < -1* x_sensitive: #microscope_control.drag_left() pass elif map_controller.center[1] - Window.center[1] > y_sensitive: #microscope_control.drag_top() print('moving y+') elif map_controller.center[1] - Window.center[1] < -1*y_sensitive: #microscope_control.drag_bot() pass elif map_controller.scale < default_scale*0.9: #microscope_control.pinch_out() print('pinch') elif map_controller.scale > default_scale*1.1: #microscope_control.pinch_in() pass #after taking actions, reset scatter location and scale to default map_controller.center = Window.center map_controller.scale = default_scale map_controller.bind(on_touch_up = map_control_feedback) return map_controller
def create_map_controller(): map_controller = Scatter( size_hint = (1,1), do_rotation=False, do_translation=True, do_scale=True) map_controller.center = Window.center # automatically determine the size based on screen size default_scale = Window.height / map_controller.height*1 # determine the size of active area map_controller.scale = default_scale # determine the amount of zoom and drag needed before moving map_controller.scale_max = default_scale*1.1 map_controller.scale_min = default_scale*0.9 x_sensitive = Window.width*0.1 y_sensitive = Window.height*0.2 # dummy object showing active area #map_controller.add_widget(Image()) def map_control_feedback(instance, value): """the callback functions for map_controller scatter object""" if map_controller.center[0] - Window.center[0] > x_sensitive: mc.stage_library('move_x', '-') elif map_controller.center[0] - Window.center[0] < -1* x_sensitive: mc.stage_library('move_x', '+') elif map_controller.center[1] - Window.center[1] > y_sensitive: mc.stage_library('move_y', '-') elif map_controller.center[1] - Window.center[1] < -1*y_sensitive: mc.stage_library('move_y', '+') elif map_controller.scale < default_scale*0.9: mc.camera_library('zoom_out') elif map_controller.scale > default_scale*1.1: mc.camera_library('zoom_in') #after taking actions, reset scatter location and scale to default map_controller.center = Window.center map_controller.scale = default_scale map_controller.bind(on_touch_up = map_control_feedback) return map_controller