Beispiel #1
0
 def drag_start(self, event):
     if self.component:
         self.original_padding = self.component.padding
         if hasattr(event, "bid"):
             event.window.capture_blob(self, event.bid,
                                       event.net_transform())
         else:
             event.window.set_mouse_owner(self, event.net_transform())
         self._last_blob_pos = (event.x, event.y)
         self.mouse_down_position = (event.x, event.y)
         self.event_state = "dragging"
         event.handled = True
         ViewportPanTool.drag_start(self, event)
     return
Beispiel #2
0
 def drag_start(self, event):
     if self.component:
         self.original_padding = self.component.padding
         if hasattr(event, "bid"):
             event.window.capture_blob(self, event.bid,
                                       event.net_transform())
         else:
             event.window.set_mouse_owner(self, event.net_transform())
         self._last_blob_pos = (event.x, event.y)
         self.mouse_down_position = (event.x,event.y)
         self.event_state = "dragging"
         event.handled = True
         ViewportPanTool.drag_start(self, event)
     return
Beispiel #3
0
    def _comp_default(self):
        canvas = Canvas(draw_axes=True, bgcolor="gray")
        self.triangle = SierpinskiTriangle(
            position=[0.0, 0.0],
            bounds=[self.base_width, self.base_width * (SQRT3 / 2)],
            iterations=self.iterations,
            max_iters=self.max_iters,
            base_width=self.base_width,
            bgcolor="gray")
        canvas.add(self.triangle)

        self.viewport = Viewport(component=canvas,
                                 enable_zoom=True,
                                 stay_inside=True)
        self.viewport.zoom_tool.min_zoom = 1.0
        self.viewport.tools.append(
            ViewportPanTool(self.viewport, drag_button="right"))

        scrolled = Scrolled(
            canvas,
            inside_padding_width=0,
            mousewheel_scroll=False,
            viewport_component=self.viewport,
            always_show_sb=True,
            continuous_drag_update=True,
        )
        return scrolled
Beispiel #4
0
    def __container_default(self):
        """ default setter for _container
        """

        viewport = Viewport(component=self._canvas, enable_zoom=True)
        viewport.view_position = [0, 0]
        viewport.tools.append(ViewportPanTool(viewport))

        return Scrolled(self._canvas, viewport_component=viewport)
Beispiel #5
0
 def create_component(self):
     canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True)
     from basic_move import Box
     box = Box(color="red", bounds=[50, 50], resizable="")
     box.position = [75, 75]
     canvas.add(box)
     viewport = Viewport(component=canvas)
     viewport.view_position = [0, 0]
     viewport.tools.append(ViewportPanTool(viewport))
     return viewport
Beispiel #6
0
    def _create_viewport(self):
        # Create a container and add our plots
        canvas = PlotCanvas()
        canvas.range_controller = RangeController(cavas = canvas)

        toolbar = make_toolbar(canvas)
        toolbar.component = canvas
        canvas.overlays.append(toolbar)

        viewport = Viewport(component=canvas)
        if MULTITOUCH:
            viewport.tools.append(MPViewportPanTool(viewport))
        else:
            viewport.tools.append(ViewportPanTool(viewport, drag_button="right"))
        return viewport
Beispiel #7
0
def main():
    manager = MBTileManager(filename='map.mbtiles', min_level=0, max_level=3)

    canvas = MappingCanvas(tile_cache=manager)

    viewport = MappingViewport(component=canvas)
    viewport.tools.append(ViewportPanTool(viewport))

    model = Model(canvas=canvas, viewport=viewport)

    import enaml
    with enaml.imports():
        from simple_view import Map
    window = Map(model=model)
    window.show()
Beispiel #8
0
    def _create_component(self):
        canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True)

        boxgridsize = 8
        boxsize = 50

        spacing = boxsize * 2
        offset = spacing / 2

        origin_color = array([0.0, 0.0, 1.0])
        x_color = array([0.0, 1.0, 0.0])
        y_color = array([1.0, 0.0, 0.0])

        for i in range(boxgridsize):
            for j in range(boxgridsize):
                color = tuple(x_color / (boxgridsize - 1) * i + y_color /
                              (boxgridsize - 1) * j + origin_color) + (1.0, )
                box = Box(color=color, bounds=[boxsize, boxsize], resizable="")
                box.position = [
                    i * spacing + offset - boxsize / 2 + 0.5,
                    j * spacing + offset - boxsize / 2 + 0.5,
                ]
                canvas.add(box)

        viewport = Viewport(
            component=canvas,
            enable_zoom=True,
            vertical_anchor="center",
            horizontal_anchor="center",
        )
        # viewport.view_position = [0,0]
        viewport.tools.append(ViewportPanTool(viewport))

        # Uncomment the following to enforce limits on the zoom
        # viewport.min_zoom = 0.1
        # viewport.max_zoom = 3.0

        scrolled = Scrolled(
            canvas,
            fit_window=True,
            inside_padding_width=0,
            mousewheel_scroll=False,
            viewport_component=viewport,
            always_show_sb=True,
            continuous_drag_update=True,
        )

        return scrolled
Beispiel #9
0
    def _offices_changed(self, new):
        viewports = []
        canvas = self.canvas
        for office in new:
            canvas.add(
                GeoMarker(
                    geoposition=office.location,
                    filename='enthought-marker.png',
                ))

            viewport = MappingViewport(component=canvas)
            viewport.tools.append(ViewportPanTool(viewport))
            viewport.set(zoom_level=canvas.tile_cache.max_level - 3,
                         geoposition=office.location)
            viewports.append(viewport)
        self.viewports = viewports
    def _create_component(self):
        canvas = DropCanvas(bgcolor="lightsteelblue", draw_axes=True)
        canvas.overlays.append(EventTracer(canvas, color="green", size=8,
                                           angle=45.0))

        viewport = Viewport(component=canvas, enable_zoom=True)
        viewport.view_position = [0, 0]
        viewport.tools.append(ViewportPanTool(viewport, drag_button="right"))
        viewport.overlays.append(EventTracer(viewport))

        scrolled = Scrolled(canvas, inside_padding_width=0,
                            mousewheel_scroll=False,
                            viewport_component=viewport,
                            always_show_sb=True,
                            continuous_drag_update=True)
        return scrolled
Beispiel #11
0
def main():
    manager = MBTileManager(filename='map.mbtiles', min_level=0, max_level=3)

    canvas = MappingCanvas(tile_cache=manager)

    canvas.add(
        GeoMarker(filename='enthought-marker.png',
                  geoposition=(40.7546423, -73.9748948)))

    viewport = MappingViewport(component=canvas)
    viewport.tools.append(ViewportPanTool(viewport))

    model = Model(canvas=canvas, viewport=viewport)

    import enaml
    with enaml.imports():
        from simple_view import Map
    window = Map(model=model)
    window.show()
Beispiel #12
0
    def add_office(self, city, location):
        offices = self.offices[:]
        viewports = self.viewports[:]

        office = Office(city=city, location=location)
        canvas = self.canvas

        canvas.add(
            GeoMarker(
                geoposition=office.location,
                filename='enthought-marker.png',
            ))

        viewport = MappingViewport(component=canvas)
        viewport.tools.append(ViewportPanTool(viewport))
        viewport.set(zoom_level=canvas.tile_cache.max_level - 3,
                     geoposition=office.location)
        offices.append(office)
        viewports.append(viewport)
        self.trait_setq(offices=offices)
        self.viewports = viewports
Beispiel #13
0
def main():
    tile_layer = MBTileManager(filename = 'map.mbtiles',
                               min_level = 2,
                               max_level = 4)

    canvas = MappingCanvas(tile_cache = tile_layer)
    canvas.overlays.append(GeoJSONOverlay(component=canvas,
                                          geojs_filename='world.geojs'))

    viewport = MappingViewport(component=canvas, zoom_level=2,
                               geoposition=(37.09024, -95.712891))
    viewport.tools.append(ViewportPanTool(viewport))

    model = SingleMap(canvas=canvas,
                      viewport=viewport)

    import enaml
    with enaml.imports():
        from simple_view import Map
    window = Map(model=model)
    window.show()
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        canvas = self.value
        viewport = CanvasViewport(component=canvas, view_position=[0, 0])
        viewport.tools.append(ViewportPanTool(viewport, drag_button='right'))
        viewport.max_zoom = 1.0
        viewport.min_zoom = 0.2
        self.canvas_view = viewport

        self.scrolled = Scrolled(canvas,
                                 fit_window=True,
                                 inside_padding_width=0,
                                 mousewheel_scroll=False,
                                 always_show_sb=True,
                                 continuous_drag_update=True,
                                 viewport_component=viewport)

        self._window = Window(parent, -1, component=self.scrolled)
        self.control = self._window.control
Beispiel #15
0
 def drag_end(self, event):
     event.x, event.y = self._last_blob_pos
     if hasattr(event, "bid"):
         event.window.release_blob(event.bid)
     self.event_state = "normal"
     ViewportPanTool.drag_end(self, event)
Beispiel #16
0
 def drag_end(self, event):
     event.x, event.y = self._last_blob_pos
     if hasattr(event, "bid"):
         event.window.release_blob(event.bid)
     self.event_state = "normal"
     ViewportPanTool.drag_end(self, event)