Пример #1
0
        def __init__(self, vectorMap):
            MapFrame.__init__(
                self,
                parent=None,
                Map=Map(),
                giface=DMonGrassInterface(None),
                title=_("Vector Digitizer - GRASS GIS"),
                size=(850, 600),
            )
            # this giface issue not solved yet, we must set mapframe aferwards
            self._giface._mapframe = self
            # load vector map
            mapLayer = self.GetMap().AddLayer(
                ltype="vector",
                name=vectorMap,
                command=["d.vect", "map=%s" % vectorMap],
                active=True,
                hidden=False,
                opacity=1.0,
                render=True,
            )

            # switch toolbar
            self.AddToolbar("vdigit", fixed=True)

            # start editing
            self.toolbars["vdigit"].StartEditing(mapLayer)
Пример #2
0
    def OnInit(self):
        if not globalvar.CheckWxVersion([2, 9]):
            wx.InitAllImageHandlers()
        if __name__ == "__main__":
            self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
            self.Map = Map(cmdfile=monFile['cmd'],
                           mapfile=monFile['map'],
                           envfile=monFile['env'],
                           monitor=monName)
        else:
            self.Map = None

        self.mapFrm = MapFrame(parent=None,
                               id=wx.ID_ANY,
                               Map=self.Map,
                               size=monSize)
        # self.SetTopWindow(Map)
        self.mapFrm.Show()

        if __name__ == "__main__":
            self.timer = wx.PyTimer(self.watcher)
            #check each 0.5s
            global mtime
            mtime = 500
            self.timer.Start(mtime)

        return True
Пример #3
0
        def __init__(
                self, new_map=None, base_map=None, edit_map=None,
                map_type=None,
        ):
            MapFrame.__init__(
                self, parent=None, Map=Map(),
                giface=DMonGrassInterface(None),
                title=_("Raster Digitizer - GRASS GIS"),
                size=(850, 600),
            )
            # this giface issue not solved yet, we must set mapframe afterwards
            self._giface._mapframe = self
            self._giface.mapCreated.connect(self.OnMapCreated)
            self._mapObj = self.GetMap()

            # load raster map
            self._addLayer(name=new_map if new_map else edit_map)

            # switch toolbar
            self.AddToolbar('rdigit', fixed=True)

            rdigit = self.toolbars['rdigit']
            if new_map:
                rdigit._mapSelectionCombo.Unbind(wx.EVT_COMBOBOX)
                self.rdigit.SelectNewMap(
                    standalone=True, mapName=new_map, bgMap=base_map,
                    mapType=map_type,
                )
                rdigit._mapSelectionCombo.Bind(
                    wx.EVT_COMBOBOX, rdigit.OnMapSelection,
                )
            else:
                rdigit._mapSelectionCombo.SetSelection(n=1)
                rdigit.OnMapSelection()
Пример #4
0
    def __init__(self, parent, giface, id=wx.ID_ANY,
                 title = _("GRASS GIS Histogramming Tool (d.histogram)"),
                 size = wx.Size(500, 350),
                 style = wx.DEFAULT_FRAME_STYLE, **kwargs):
        wx.Frame.__init__(self, parent, id, title, size = size, style = style, **kwargs)
        self.SetIcon(wx.Icon(os.path.join(globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))

        self._giface = giface
        self.Map   = Map()         # instance of render.Map to be associated with display
        self.layer = None          # reference to layer with histogram
        
        # Init variables
        self.params = {}  # previously set histogram parameters
        self.propwin = '' # ID of properties dialog
        
        self.font = ""
        self.encoding = 'ISO-8859-1' # default encoding for display fonts
        
        self.toolbar = HistogramToolbar(parent = self)
        # workaround for http://trac.wxwidgets.org/ticket/13888
        if sys.platform != 'darwin':
            self.SetToolBar(self.toolbar)

        # find selected map
        # might by moved outside this class
        # setting to None but honestly we do not handle no map case
        # TODO: when self.mapname is None content of map window is showed
        self.mapname = None
        layers = self._giface.GetLayerList().GetSelectedLayers(checkedOnly=False)
        if len(layers) > 0:
            self.mapname = layers[0].maplayer.name

        # Add statusbar
        self.statusbar = self.CreateStatusBar(number = 1, style = 0)
        # self.statusbar.SetStatusWidths([-2, -1])
        hist_frame_statusbar_fields = ["Histogramming %s" % self.mapname]
        for i in range(len(hist_frame_statusbar_fields)):
            self.statusbar.SetStatusText(hist_frame_statusbar_fields[i], i)
        
        # Init map display
        self.InitDisplay() # initialize region values
        
        # initialize buffered DC
        self.HistWindow = BufferedWindow(self, id = wx.ID_ANY, Map = self.Map) # initialize buffered DC
        
        # Bind various events
        self.Bind(wx.EVT_CLOSE,    self.OnCloseWindow)
        
        # Init print module and classes
        self.printopt = PrintOptions(self, self.HistWindow)
        
        # Add layer to the map
        self.layer = self.Map.AddLayer(ltype = "command", name = 'histogram', command = [['d.histogram']],
                                       active = False, hidden = False, opacity = 1, render = False)
        if self.mapname:
            self.SetHistLayer(self.mapname, None)
        else:
            self.OnErase(None)
            wx.CallAfter(self.OnOptions, None)
Пример #5
0
def main():
    """Sets the GRASS display driver
    """
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # TODO: message format should not be GUI
    # TODO: should messages here be translatable?
    # (for test its great, for translator not)

    options, flags = grass.parser()
    test = options['test']

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    map_ = Map()

    if options['raster']:
        names = options['raster']
        for name in names.split(','):
            cmdlist = ['d.rast', 'map=%s' % name]
            map_.AddLayer(ltype='raster', command=cmdlist, active=True,
                          name=name, hidden=False, opacity=1.0,
                          render=True)
    if options['vector']:
        names = options['vector']
        for name in names.split(','):
            cmdlist = ['d.vect', 'map=%s' % name]
            map_.AddLayer(ltype='vector', command=cmdlist, active=True,
                          name=name, hidden=False, opacity=1.0,
                          render=True)

    giface = MapdispGrassInterface(map_=map_)
    tester = Tester()

    if test == 'mapwindow':
        tester.testMapWindow(giface, map_)
    elif test == 'mapdisplay':
        tester.testMapDisplay(giface, map_)
    elif test == 'apitest':
        tester.testMapWindowApi(giface, map_)
    elif test == 'distance':
        tester.testMapWindowDistance(giface, map_)
    elif test == 'profile':
        tester.testMapWindowProfile(giface, map_)
    elif test == 'rlisetup':
        tester.testMapWindowRlisetup(map_)
    else:
        # TODO: this should not happen but happens
        import grass.script as sgrass
        sgrass.fatal(_("Unknown value %s of test parameter." % test))

    app.MainLoop()
Пример #6
0
    def __buildPreviewPanel(self):
        """
        Creates preview panel.
        :return: void
        """
        #Output preview
        self.map = Map()
        self.width = self.map.width = 400
        self.height = self.map.height = 300
        self.map.geom = self.width, self.height

        self.preview = BufferedWindow(parent=self,
                                      id=wx.NewId(),
                                      size=(400, 300),
                                      Map=self.map)
        self.preview.EraseMap()
Пример #7
0
        def __init__(self, parent, vectorMap):
            MapPanel.__init__(self,
                              parent=parent,
                              Map=Map(),
                              giface=DMonGrassInterface(None))

            # set system icon
            parent.SetIcon(
                wx.Icon(os.path.join(ICONDIR, "grass_map.ico"),
                        wx.BITMAP_TYPE_ICO))

            # bindings
            parent.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

            # extend shortcuts and create frame accelerator table
            self.shortcuts_table.append(
                (self.OnFullScreen, wx.ACCEL_NORMAL, wx.WXK_F11))
            self._initShortcuts()

            # this giface issue not solved yet, we must set mapframe aferwards
            self._giface._mapframe = self
            # load vector map
            mapLayer = self.GetMap().AddLayer(
                ltype="vector",
                name=vectorMap,
                command=["d.vect", "map=%s" % vectorMap],
                active=True,
                hidden=False,
                opacity=1.0,
                render=True,
            )

            # switch toolbar
            self.AddToolbar("vdigit", fixed=True)

            # start editing
            self.toolbars["vdigit"].StartEditing(mapLayer)
            # use Close instead of QuitVDigit for standalone tool
            self.toolbars["vdigit"].quitDigitizer.disconnect(self.QuitVDigit)
            self.toolbars["vdigit"].quitDigitizer.connect(lambda: self.Close())

            # add Map Display panel to Map Display frame
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self, proportion=1, flag=wx.EXPAND)
            parent.SetSizer(sizer)
            parent.Layout()
Пример #8
0
    def __init__(self, parent=None, giface=None,
                 title=_("GRASS GIS Map Swipe"), name="swipe", **kwargs):
        DoubleMapFrame.__init__(self, parent=parent, title=title, name=name,
                                firstMap=Map(), secondMap=Map(), **kwargs)
        Debug.msg(1, "SwipeMapFrame.__init__()")
        #
        # Add toolbars
        #
        self.AddToolbars()
        self._giface = giface
        #
        # create widgets
        #
        self.splitter = MapSplitter(parent=self, id=wx.ID_ANY)

        self.sliderH = wx.Slider(self, id=wx.ID_ANY, style=wx.SL_HORIZONTAL)
        self.sliderV = wx.Slider(self, id=wx.ID_ANY, style=wx.SL_VERTICAL)

        self.mapWindowProperties = MapWindowProperties()
        self.mapWindowProperties.setValuesFromUserSettings()
        self.mapWindowProperties.autoRenderChanged.connect(
            self.OnAutoRenderChanged)
        self.firstMapWindow = SwipeBufferedWindow(
            parent=self.splitter, giface=self._giface,
            properties=self.mapWindowProperties, Map=self.firstMap)
        self.secondMapWindow = SwipeBufferedWindow(
            parent=self.splitter, giface=self._giface,
            properties=self.mapWindowProperties, Map=self.secondMap)
        # bind query signal
        self.firstMapWindow.mapQueried.connect(self.Query)
        self.secondMapWindow.mapQueried.connect(self.Query)

        # bind tracking cursosr to mirror it
        self.firstMapWindow.Bind(
            wx.EVT_MOTION,
            lambda evt: self.TrackCursor(evt))
        self.secondMapWindow.Bind(
            wx.EVT_MOTION,
            lambda evt: self.TrackCursor(evt))

        self.MapWindow = self.firstMapWindow  # current by default
        self.firstMapWindow.zoomhistory = self.secondMapWindow.zoomhistory
        self.SetBindRegions(True)

        self._mode = 'swipe'

        self._addPanes()
        self._bindWindowsActivation()
        self._setUpMapWindow(self.firstMapWindow)
        self._setUpMapWindow(self.secondMapWindow)

        self._mgr.GetPane('sliderV').Hide()
        self._mgr.GetPane('sliderH').Show()
        self.slider = self.sliderH

        self.InitStatusbar()

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        self.SetSize((800, 600))

        self._mgr.Update()

        self.rasters = {'first': None, 'second': None}

        self._inputDialog = None
        self._preferencesDialog = None
        self._queryDialog = None

        # default action in map toolbar
        self.GetMapToolbar().SelectDefault()

        self.resize = False

        wx.CallAfter(self.CallAfterInit)
Пример #9
0
    def __init__(
        self, parent=None, giface=None, title=_("Map Swipe"), name="swipe", **kwargs
    ):
        DoubleMapPanel.__init__(
            self,
            parent=parent,
            title=title,
            name=name,
            firstMap=Map(),
            secondMap=Map(),
            **kwargs,
        )
        Debug.msg(1, "SwipeMapPanel.__init__()")
        #
        # Add toolbars
        #
        for name in ("swipeMain", "swipeMap", "swipeMisc"):
            self.AddToolbar(name)
        self._mgr.Update()

        self._giface = giface
        #
        # create widgets
        #
        self.splitter = MapSplitter(parent=self, id=wx.ID_ANY)

        self.sliderH = Slider(self, id=wx.ID_ANY, style=wx.SL_HORIZONTAL)
        self.sliderV = Slider(self, id=wx.ID_ANY, style=wx.SL_VERTICAL)

        self.mapWindowProperties.autoRenderChanged.connect(self.OnAutoRenderChanged)
        self.firstMapWindow = SwipeBufferedWindow(
            parent=self.splitter,
            giface=self._giface,
            properties=self.mapWindowProperties,
            Map=self.firstMap,
        )
        self.secondMapWindow = SwipeBufferedWindow(
            parent=self.splitter,
            giface=self._giface,
            properties=self.mapWindowProperties,
            Map=self.secondMap,
        )
        # bind query signal
        self.firstMapWindow.mapQueried.connect(self.Query)
        self.secondMapWindow.mapQueried.connect(self.Query)

        # bind tracking cursosr to mirror it
        self.firstMapWindow.Bind(wx.EVT_MOTION, lambda evt: self.TrackCursor(evt))
        self.secondMapWindow.Bind(wx.EVT_MOTION, lambda evt: self.TrackCursor(evt))

        self.MapWindow = self.firstMapWindow  # current by default
        self.firstMapWindow.zoomhistory = self.secondMapWindow.zoomhistory
        self.SetBindRegions(True)

        self._mode = "swipe"

        # statusbar items
        statusbarItems = [
            sb.SbCoordinates,
            sb.SbRegionExtent,
            sb.SbCompRegionExtent,
            sb.SbDisplayGeometry,
            sb.SbMapScale,
            sb.SbGoTo,
        ]
        self.statusbar = self.CreateStatusbar(statusbarItems)

        self._addPanes()
        self._bindWindowsActivation()
        self._setUpMapWindow(self.firstMapWindow)
        self._setUpMapWindow(self.secondMapWindow)

        self._mgr.GetPane("sliderV").Hide()
        self._mgr.GetPane("sliderH").Show()
        self.slider = self.sliderH

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_IDLE, self.OnIdle)

        self.SetSize((800, 600))

        self._mgr.Update()

        self.rasters = {"first": None, "second": None}

        self._inputDialog = None
        self._preferencesDialog = None
        self._queryDialog = None

        # default action in map toolbar
        self.GetMapToolbar().SelectDefault()

        self.resize = False

        wx.CallAfter(self.CallAfterInit)
Пример #10
0
    def __init__(self, parent, samplingType, icon=None, map_=None):
        wx.Panel.__init__(self, parent=parent)

        self.mapWindowProperties = MapWindowProperties()
        self.mapWindowProperties.setValuesFromUserSettings()
        giface = StandaloneGrassInterface()
        self.samplingtype = samplingType
        self.parent = parent

        if map_:
            self.map_ = map_
        else:
            self.map_ = Map()
        self.map_.region = self.map_.GetRegion()

        self._mgr = wx.aui.AuiManager(self)
        self.mapWindow = BufferedMapWindow(parent=self, giface=giface,
                                           Map=self.map_,
                                           properties=self.mapWindowProperties)
        self._mgr.AddPane(self.mapWindow, wx.aui.AuiPaneInfo().CentrePane().
                          Dockable(True).BestSize((-1, -1)).Name('mapwindow').
                          CloseButton(False).DestroyOnClose(True).
                          Layer(0))
        self._toolSwitcher = ToolSwitcher()
        self._toolSwitcher.toggleToolChanged.connect(self._onToolChanged)
        self.toolbar = RLiSetupToolbar(self, self._toolSwitcher)

        self.catId = 1

        self._mgr.AddPane(self.toolbar,
                          wx.aui.AuiPaneInfo().
                          Name("maptoolbar").Caption(_("Map Toolbar")).
                          ToolbarPane().Left().Name('mapToolbar').
                          CloseButton(False).Layer(1).Gripper(False).
                          BestSize((self.toolbar.GetBestSize())))
        self._mgr.Update()

        if self.samplingtype == SamplingType.REGIONS:
            self.afterRegionDrawn = Signal('RLiSetupMapPanel.afterRegionDrawn')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='line')
        elif self.samplingtype in [SamplingType.MUNITSR, SamplingType.MMVWINR]:
            self.sampleFrameChanged = Signal(
                'RLiSetupMapPanel.sampleFrameChanged')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='rectangle')
        elif self.samplingtype in [SamplingType.MUNITSC, SamplingType.MMVWINC]:
            self.afterCircleDrawn = Signal('RLiSetupMapPanel.afterCircleDrawn')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='line')
        else:
            self.sampleFrameChanged = Signal(
                'RLiSetupMapPanel.sampleFrameChanged')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='rectangle')

        self._registeredGraphics.AddPen('rlisetup', wx.Pen(wx.GREEN, width=2,
                                                           style=wx.SOLID))
        self._registeredGraphics.AddItem(coords=[[0, 0], [0, 0]],
                                         penName='rlisetup', hide=True)

        if self.samplingtype != SamplingType.VECT:
            self.toolbar.SelectDefault()
Пример #11
0
    def __init__(
        self,
        parent,
        giface,
        title=_("Example Tool"),
        toolbars=["MiscToolbar", "MapToolbar", "MainToolbar"],
        size=(800, 600),
        name="exampleWindow",
        **kwargs,
    ):
        """!Map Frame constructor

        @param parent (no parent is expected)
        @param title window title
        @param toolbars list of active toolbars (default value represents all toolbars)
        @param size default size
        """
        SingleMapFrame.__init__(
            self, parent=parent, title=title, name=name, Map=Map(), **kwargs
        )

        # Place debug message where appropriate
        # and set debug level from 1 to 5 (higher to lower level functions).
        # To enable debug mode write:
        # > g.gisenv set=WX_DEBUG=5
        Debug.msg(1, "ExampleMapFrame.__init__()")

        #
        # Add toolbars to aui manager
        #
        toolbarsCopy = toolbars[:]
        # workaround to have the same toolbar order on all platforms
        if sys.platform == "win32":
            toolbarsCopy.reverse()

        for toolbar in toolbarsCopy:
            self.AddToolbar(toolbar)

        self.mapWindowProperties = MapWindowProperties()
        self.mapWindowProperties.setValuesFromUserSettings()
        self.mapWindowProperties.autoRenderChanged.connect(
            lambda value: self.OnRender(None) if value else None
        )
        #
        # Add statusbar
        #

        # choose items in statusbar choice, which makes sense for your application
        self.statusbarItems = [
            sb.SbCoordinates,
            sb.SbRegionExtent,
            sb.SbCompRegionExtent,
            sb.SbShowRegion,
            sb.SbAlignExtent,
            sb.SbResolution,
            sb.SbDisplayGeometry,
            sb.SbMapScale,
            sb.SbGoTo,
            sb.SbProjection,
        ]

        # create statusbar and its manager
        statusbar = self.CreateStatusBar(number=4, style=0)
        statusbar.SetStatusWidths([-5, -2, -1, -1])
        self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar)

        # fill statusbar manager
        self.statusbarManager.AddStatusbarItemsByClass(
            self.statusbarItems, mapframe=self, statusbar=statusbar
        )
        self.statusbarManager.AddStatusbarItem(
            sb.SbMask(self, statusbar=statusbar, position=2)
        )
        self.statusbarManager.AddStatusbarItem(
            sb.SbRender(self, statusbar=statusbar, position=3)
        )

        self.statusbarManager.Update()

        # create map window
        self.MapWindow = BufferedMapWindow(
            parent=self,
            Map=self.GetMap(),
            properties=self.mapWindowProperties,
            giface=self,
        )
        self._setUpMapWindow(self.MapWindow)
        self.MapWindow.InitZoomHistory()

        # create whatever you want, here it is a widget for displaying raster info
        self.info = ExampleInfoTextManager(self)

        # add map window (and other widgets) to aui manager
        self._addPanes()
        self._mgr.Update()

        # initialize variables related to your application functionality
        self.InitVariables()

        # default action
        self.GetMapToolbar().SelectDefault()

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        self.SetSize(size)
Пример #12
0
    def __init__(self,
                 parent=None,
                 size=wx.Size(700, 400),
                 style=wx.DEFAULT_FRAME_STYLE,
                 rasterList=[],
                 **kwargs):

        wx.Frame.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          size=size,
                          style=style,
                          **kwargs)

        self.parent = parent  # MapFrame for a plot type
        self.Map = Map(
        )  # instance of render.Map to be associated with display
        self.rasterList = rasterList  # list of rasters to plot
        self.raster = {
        }  # dictionary of raster maps and their plotting parameters
        self.plottype = ''

        self.linestyledict = {
            'solid': wx.SOLID,
            'dot': wx.DOT,
            'long-dash': wx.LONG_DASH,
            'short-dash': wx.SHORT_DASH,
            'dot-dash': wx.DOT_DASH
        }

        self.ptfilldict = {'transparent': wx.TRANSPARENT, 'solid': wx.SOLID}

        #
        # Icon
        #
        self.SetIcon(
            wx.Icon(os.path.join(ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))

        #
        # Add statusbar
        #
        self.statusbar = self.CreateStatusBar(number=2, style=0)
        self.statusbar.SetStatusWidths([-2, -1])

        #
        # Define canvas and settings
        #
        #
        self.client = plot.PlotCanvas(self)

        # define the function for drawing pointLabels
        self.client.SetPointLabelFunc(self.DrawPointLabel)

        # Create mouse event for showing cursor coords in status bar
        self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)

        # Show closest point when enabled
        self.client.canvas.Bind(wx.EVT_MOTION, self.OnMotion)

        self.plotlist = []  # list of things to plot
        self.plot = None  # plot draw object
        self.ptitle = ""  # title of window
        self.xlabel = ""  # default X-axis label
        self.ylabel = ""  # default Y-axis label

        self.CentreOnScreen()

        self._createColorDict()
Пример #13
0
    def __init__(
        self,
        parent=None,
        giface=None,
        title=_("Raster Digitizer"),
        toolbars=["digitMap", "rdigit"],
        size=(875, 600),
        name="RDigitWindow",
        **kwargs
    ):
        """!
        @param parent (no parent is expected)
        @param title window title
        @param toolbars dictionary of active toolbars (defalult value represents all toolbars)
        @param size default size
        """
        SingleMapFrame.__init__(
            self, parent=parent, title=title, name=name, Map=Map(), **kwargs
        )
        self._giface = giface

        self.MapWindow = RDigitWindow(
            parent=self, giface=self._giface, id=wx.ID_ANY, frame=self, Map=self.Map
        )
        self.outMapName = None

        self.mapManager = MapManager(self, mapWindow=self.MapWindow, Map=self.GetMap())
        self.SetSize(size)
        # MapWindowRDigit

        # Add toolbars
        toolbarsCopy = toolbars[:]
        if sys.platform == "win32":
            self.AddToolbar(toolbarsCopy.pop(1))
            toolbarsCopy.reverse()
        else:
            self.AddToolbar(toolbarsCopy.pop(0))
        for toolb in toolbarsCopy:
            self.AddToolbar(toolb)

        self.GetMapToolbar().Bind(wx.EVT_CHOICE, self.OnUpdateActive)

        # items for choice
        self.statusbarItems = [
            sb.SbCoordinates,
            sb.SbRegionExtent,
            sb.SbCompRegionExtent,
            sb.SbShowRegion,
            sb.SbAlignExtent,
            sb.SbResolution,
            sb.SbDisplayGeometry,
            sb.SbMapScale,
            sb.SbGoTo,
            sb.SbProjection,
        ]

        # create statusbar and its manager
        statusbar = self.CreateStatusBar(number=4, style=0)
        statusbar.SetStatusWidths([-5, -2, -1, -1])
        self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar)

        # fill statusbar manager
        self.statusbarManager.AddStatusbarItemsByClass(
            self.statusbarItems, mapframe=self, statusbar=statusbar
        )
        self.statusbarManager.AddStatusbarItem(
            sb.SbMask(self, statusbar=statusbar, position=2)
        )
        self.statusbarManager.AddStatusbarItem(
            sb.SbRender(self, statusbar=statusbar, position=3)
        )
        self.statusbarManager.Update()

        self.changes = False

        self._addPanes()
        self._mgr.Update()

        self.mapManager.SetToolbar(self.toolbars["digitMap"])

        # default action
        self.OnPan(event=None)

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
Пример #14
0
def main():
    """Sets the GRASS display driver"""
    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    # TODO: message format should not be GUI
    # TODO: should messages here be translatable?
    # (for test its great, for translator not)

    options, flags = grass.parser()
    test = options["test"]

    app = wx.App()
    map_ = Map()

    if options["raster"]:
        names = options["raster"]
        for name in names.split(","):
            cmdlist = ["d.rast", "map=%s" % name]
            map_.AddLayer(
                ltype="raster",
                command=cmdlist,
                active=True,
                name=name,
                hidden=False,
                opacity=1.0,
                render=True,
            )
    if options["vector"]:
        names = options["vector"]
        for name in names.split(","):
            cmdlist = ["d.vect", "map=%s" % name]
            map_.AddLayer(
                ltype="vector",
                command=cmdlist,
                active=True,
                name=name,
                hidden=False,
                opacity=1.0,
                render=True,
            )

    giface = MapdispGrassInterface(map_=map_)
    tester = Tester()

    if test == "mapwindow":
        tester.testMapWindow(giface, map_)
    elif test == "mapdisplay":
        tester.testMapDisplay(giface, map_)
    elif test == "apitest":
        tester.testMapWindowApi(giface, map_)
    elif test == "distance":
        tester.testMapWindowDistance(giface, map_)
    elif test == "profile":
        tester.testMapWindowProfile(giface, map_)
    elif test == "rlisetup":
        tester.testMapWindowRlisetup(map_)
    else:
        # TODO: this should not happen but happens
        import grass.script as sgrass

        sgrass.fatal(_("Unknown value %s of test parameter." % test))

    app.MainLoop()
Пример #15
0
    def __init__(self,
                 parent=None,
                 id=wx.ID_ANY,
                 title=_("GRASS GIS Histogramming Tool (d.histogram)"),
                 size=wx.Size(500, 350),
                 style=wx.DEFAULT_FRAME_STYLE,
                 **kwargs):
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          size=size,
                          style=style,
                          **kwargs)
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'),
                    wx.BITMAP_TYPE_ICO))

        self.Map = Map(
        )  # instance of render.Map to be associated with display
        self.layer = None  # reference to layer with histogram

        # Init variables
        self.params = {}  # previously set histogram parameters
        self.propwin = ''  # ID of properties dialog

        self.font = ""
        self.encoding = 'ISO-8859-1'  # default encoding for display fonts

        self.toolbar = HistogramToolbar(parent=self)
        self.SetToolBar(self.toolbar)

        # find selected map
        self.mapname = None
        if parent.GetName() == "MapWindow" and not parent.IsStandalone():
            tree = parent.GetLayerManager().GetLayerTree()

            if tree.layer_selected and tree.GetPyData(
                    tree.layer_selected)[0]['type'] == 'raster':
                self.mapname = tree.GetPyData(
                    tree.layer_selected)[0]['maplayer'].name

        # Add statusbar
        self.statusbar = self.CreateStatusBar(number=1, style=0)
        # self.statusbar.SetStatusWidths([-2, -1])
        hist_frame_statusbar_fields = ["Histogramming %s" % self.mapname]
        for i in range(len(hist_frame_statusbar_fields)):
            self.statusbar.SetStatusText(hist_frame_statusbar_fields[i], i)

        # Init map display
        self.InitDisplay()  # initialize region values

        # initialize buffered DC
        self.HistWindow = BufferedWindow(
            self, id=wx.ID_ANY, Map=self.Map)  # initialize buffered DC

        # Bind various events
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        # Init print module and classes
        self.printopt = PrintOptions(self, self.HistWindow)

        # Add layer to the map
        self.layer = self.Map.AddLayer(type="command",
                                       name='histogram',
                                       command=[['d.histogram']],
                                       l_active=False,
                                       l_hidden=False,
                                       l_opacity=1,
                                       l_render=False)
        if self.mapname:
            self.SetHistLayer(self.mapname, None)
        else:
            self.OnErase(None)
Пример #16
0
        def __init__(
            self,
            parent,
            new_map=None,
            base_map=None,
            edit_map=None,
            map_type=None,
        ):
            MapPanel.__init__(self,
                              parent=parent,
                              Map=Map(),
                              giface=DMonGrassInterface(None))

            # set system icon
            parent.SetIcon(
                wx.Icon(os.path.join(ICONDIR, "grass_map.ico"),
                        wx.BITMAP_TYPE_ICO))

            # bindings
            parent.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

            # extend shortcuts and create frame accelerator table
            self.shortcuts_table.append(
                (self.OnFullScreen, wx.ACCEL_NORMAL, wx.WXK_F11))
            self._initShortcuts()

            # this giface issue not solved yet, we must set mapframe afterwards
            self._giface._mapframe = self
            self._giface.mapCreated.connect(self.OnMapCreated)
            self._mapObj = self.GetMap()

            # load raster map
            self._addLayer(name=new_map if new_map else edit_map)

            # switch toolbar
            self.AddToolbar("rdigit", fixed=True)

            rdigit = self.toolbars["rdigit"]
            if new_map:
                rdigit._mapSelectionCombo.Unbind(wx.EVT_COMBOBOX)
                self.rdigit.SelectNewMap(
                    standalone=True,
                    mapName=new_map,
                    bgMap=base_map,
                    mapType=map_type,
                )
                rdigit._mapSelectionCombo.Bind(
                    wx.EVT_COMBOBOX,
                    rdigit.OnMapSelection,
                )
            else:
                rdigit._mapSelectionCombo.SetSelection(n=1)
                rdigit.OnMapSelection()
            # use Close instead of QuitRDigit for standalone tool
            self.rdigit.quitDigitizer.disconnect(self.QuitRDigit)
            self.rdigit.quitDigitizer.connect(lambda: self.Close())

            # add Map Display panel to Map Display frame
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self, proportion=1, flag=wx.EXPAND)
            parent.SetSizer(sizer)
            parent.Layout()