Exemplo n.º 1
0
    def testMapWindowProfile(self, giface, map_):
        self.frame = wx.Frame(parent=None,
                              title=_("Map window profile tool test frame"))
        panel = wx.Panel(parent=self.frame, id=wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)

        mapWindowProperties = MapWindowProperties()
        mapWindowProperties.setValuesFromUserSettings()
        mapWindowProperties.showRegion = True

        width, height = self.frame.GetClientSize()
        copyOfInitMap(map_, width, height)
        window = BufferedMapWindow(parent=panel,
                                   giface=giface,
                                   Map=map_,
                                   properties=mapWindowProperties)

        giface.mapWindow = window

        sizer.Add(window, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        panel.SetSizer(sizer)
        panel.Layout()

        window.ZoomToWind()

        self._listenToAllMapWindowSignals(window)

        self.frame.Show()

        from mapwin.analysis import ProfileController

        self.controller = ProfileController(giface, window)
        self.controller.Start()

        rasters = []
        for layer in giface.GetLayerList().GetSelectedLayers():
            if layer.maplayer.GetType() == "raster":
                rasters.append(layer.maplayer.GetName())

        from wxplot.profile import ProfileFrame

        profileWindow = ProfileFrame(
            parent=self.frame,
            giface=giface,
            controller=self.controller,
            units=map_.projinfo["units"],
            rasterList=rasters,
        )
        profileWindow.CentreOnParent()
        profileWindow.Show()
        # Open raster select dialog to make sure that a raster (and
        # the desired raster) is selected to be profiled
        profileWindow.OnSelectRaster(None)
Exemplo n.º 2
0
    def testMapWindowDistance(self, giface, map_):
        self.frame = wx.Frame(
            parent=None, title=_("Map window distance measurement test frame"))
        panel = wx.Panel(parent=self.frame, id=wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)

        mapWindowProperties = MapWindowProperties()
        mapWindowProperties.setValuesFromUserSettings()
        mapWindowProperties.showRegion = True

        width, height = self.frame.GetClientSize()
        copyOfInitMap(map_, width, height)
        window = BufferedMapWindow(parent=panel,
                                   giface=giface,
                                   Map=map_,
                                   properties=mapWindowProperties)

        giface.mapWindow = window

        sizer.Add(window, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        panel.SetSizer(sizer)
        panel.Layout()

        window.ZoomToWind()

        self._listenToAllMapWindowSignals(window)

        self.frame.Show()

        from mapwin.analysis import MeasureDistanceController
        self.controller = MeasureDistanceController(giface, window)
        self.controller.Start()
Exemplo n.º 3
0
class Tester(object):
    def _listenToAllMapWindowSignals(self, window):
        output = sys.stderr
        # will make bad thigs after it is closed but who cares
        coordinatesShower = TextShower(window, "Coordinates")

        window.zoomChanged.connect(lambda: output.write("zoomChanged\n"))
        window.zoomHistoryUnavailable.connect(
            lambda: output.write("zoomHistoryUnavailable\n"))
        window.zoomHistoryAvailable.connect(
            lambda: output.write("zoomHistoryAvailable\n"))

        window.mapQueried.connect(lambda: output.write("mapQueried\n"))
        window.mouseEntered.connect(lambda: output.write("mouseEntered\n"))
        window.mouseLeftUpPointer.connect(
            lambda: output.write("mouseLeftUpPointer\n"))
        window.mouseLeftUp.connect(lambda: output.write("mouseLeftUp\n"))
        window.mouseMoving.connect(
            lambda x, y: coordinatesShower.SetLabel("%s , %s" % (x, y)))
        window.mouseHandlerRegistered.connect(
            lambda: output.write("mouseHandlerRegistered\n"))
        window.mouseHandlerUnregistered.connect(
            lambda: output.write("mouseHandlerUnregistered\n"))

    def testMapWindow(self, giface, map_):
        self.frame = wx.Frame(parent=None, title=_("Map window test frame"))
        panel = wx.Panel(parent=self.frame, id=wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)
        mapWindowProperties = MapWindowProperties()
        mapWindowProperties.setValuesFromUserSettings()
        width, height = self.frame.GetClientSize()
        copyOfInitMap(map_, width, height)
        window = BufferedMapWindow(parent=panel,
                                   giface=giface,
                                   Map=map_,
                                   properties=mapWindowProperties)
        sizer.Add(window, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        panel.SetSizer(sizer)
        panel.Layout()
        self.frame.Show()

    def testMapDisplay(self, giface, map_):
        from mapdisp.frame import MapFrame
        # known issues (should be similar with d.mon):
        # * opening map in digitizer ends with: vdigit/toolbars.py:723: 'selection' referenced before assignment
        # * nviz start fails (closes window? segfaults?) after mapdisp/frame.py:306: 'NoneType' object has no attribute 'GetLayerNotebook'
        frame = MapFrame(parent=None,
                         title=_("Map display test"),
                         giface=giface,
                         Map=map_)
        # this is questionable: how complete the giface when creating objects
        # which are in giface
        giface.mapWindow = frame.GetMapWindow()
        frame.GetMapWindow().ZoomToMap()
        frame.Show()

    def testMapWindowApi(self, giface, map_):
        self.frame = wx.Frame(parent=None,
                              title=_("Map window API test frame"))
        panel = wx.Panel(parent=self.frame, id=wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)

        mapWindowProperties = MapWindowProperties()
        mapWindowProperties.setValuesFromUserSettings()
        mapWindowProperties.showRegion = True

        width, height = self.frame.GetClientSize()
        copyOfInitMap(map_, width, height)
        window = BufferedMapWindow(parent=panel,
                                   giface=giface,
                                   Map=map_,
                                   properties=mapWindowProperties)

        giface.mapWindow = window

        sizer.Add(window, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        panel.SetSizer(sizer)
        panel.Layout()

        window.ZoomToWind()

        self.frame.Show()

    def testMapWindowDistance(self, giface, map_):
        self.frame = wx.Frame(
            parent=None, title=_("Map window distance measurement test frame"))
        panel = wx.Panel(parent=self.frame, id=wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)

        mapWindowProperties = MapWindowProperties()
        mapWindowProperties.setValuesFromUserSettings()
        mapWindowProperties.showRegion = True

        width, height = self.frame.GetClientSize()
        copyOfInitMap(map_, width, height)
        window = BufferedMapWindow(parent=panel,
                                   giface=giface,
                                   Map=map_,
                                   properties=mapWindowProperties)

        giface.mapWindow = window

        sizer.Add(window, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        panel.SetSizer(sizer)
        panel.Layout()

        window.ZoomToWind()

        self._listenToAllMapWindowSignals(window)

        self.frame.Show()

        from mapwin.analysis import MeasureDistanceController
        self.controller = MeasureDistanceController(giface, window)
        self.controller.Start()

    def testMapWindowProfile(self, giface, map_):
        self.frame = wx.Frame(parent=None,
                              title=_("Map window profile tool test frame"))
        panel = wx.Panel(parent=self.frame, id=wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)

        mapWindowProperties = MapWindowProperties()
        mapWindowProperties.setValuesFromUserSettings()
        mapWindowProperties.showRegion = True

        width, height = self.frame.GetClientSize()
        copyOfInitMap(map_, width, height)
        window = BufferedMapWindow(parent=panel,
                                   giface=giface,
                                   Map=map_,
                                   properties=mapWindowProperties)

        giface.mapWindow = window

        sizer.Add(window, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        panel.SetSizer(sizer)
        panel.Layout()

        window.ZoomToWind()

        self._listenToAllMapWindowSignals(window)

        self.frame.Show()

        from mapwin.analysis import ProfileController
        self.controller = ProfileController(giface, window)
        self.controller.Start()

        rasters = []
        for layer in giface.GetLayerList().GetSelectedLayers():
            if layer.maplayer.GetType() == 'raster':
                rasters.append(layer.maplayer.GetName())

        from wxplot.profile import ProfileFrame
        profileWindow = ProfileFrame(parent=self.frame,
                                     giface=giface,
                                     controller=self.controller,
                                     units=map_.projinfo['units'],
                                     rasterList=rasters)
        profileWindow.CentreOnParent()
        profileWindow.Show()
        # Open raster select dialog to make sure that a raster (and
        # the desired raster) is selected to be profiled
        profileWindow.OnSelectRaster(None)

    def testMapWindowRlisetup(self, map_):
        self.frame = wx.Frame(parent=None,
                              title=_("Map window rlisetup test frame"))

        RLiSetupMapPanel(parent=self.frame, map_=map_)
        self.frame.Show()