Beispiel #1
0
 def SetIsosurfaceDefaultProp(self):
     """Set default isosurface properties"""
     data = dict()
     for attr in ('shine', 'topo', 'transp', 'color', 'inout'):
         data[attr] = {}
         data[attr]['update'] = None
         if attr == 'inout':
             data[attr]['value'] = 0
             continue
         for key, value in UserSettings.Get(group='nviz',
                                            key='volume',
                                            subkey=attr).iteritems():
             data[attr][key] = value
     return data
Beispiel #2
0
 def SetIsosurfaceDefaultProp(self):
     """Set default isosurface properties"""
     data = dict()
     for attr in ("shine", "topo", "transp", "color", "inout"):
         data[attr] = {}
         data[attr]["update"] = None
         if attr == "inout":
             data[attr]["value"] = 0
             continue
         for key, value in six.iteritems(
             UserSettings.Get(group="nviz", key="volume", subkey=attr)
         ):
             data[attr][key] = value
     return data
Beispiel #3
0
    def _updateBitmapData(self):
        # unload previous data
        self.bitmapProvider.Unload()

        # load new data
        for animData in self.animationData:
            if animData.viewMode == '2d':
                self._set2DData(animData)
            else:
                self._load3DData(animData)
            self._loadLegend(animData)
        color = UserSettings.Get(
            group='animation',
            key='bgcolor',
            subkey='color')
        cpus = UserSettings.Get(
            group='animation',
            key='nprocs',
            subkey='value')
        self.bitmapProvider.Load(nprocs=cpus, bgcolor=color)
        # clear pools
        self.bitmapPool.Clear()
        self.mapFilesPool.Clear()
Beispiel #4
0
    def Update(self):
        self.statusbar.SetStatusText("")
        epsg = UserSettings.Get(group='projection',
                                key='statusbar',
                                subkey='epsg')
        if epsg:
            label = '%s (EPSG: %s)' % (self.defaultLabel, epsg)
            self.widget.SetLabel(label)
        else:
            self.widget.SetLabel(self.defaultLabel)
        self.Show()

        # disable long help
        self.mapFrame.StatusbarEnableLongHelp(False)
Beispiel #5
0
    def _postInit(self):
        """Post-initialization method

        It sets internal user settings,
        set selection (from map display settings) and does reposition.
        It is called automatically.
        """
        UserSettings.Set(
            group="display",
            key="statusbarMode",
            subkey="choices",
            value=self.GetItemLabels(),
            settings_type="internal",
        )
        if not self._modeIndexSet:
            self.SetMode(
                UserSettings.Get(
                    group="display", key="statusbarMode", subkey="selection"
                )
            )
        self.Reposition()

        self._postInitialized = True
Beispiel #6
0
    def OnChangeCategoryMode(self, event):
        """Change category mode
        """
        mode = event.GetSelection()
        UserSettings.Set(
            group='vdigit',
            key="categoryMode",
            subkey='selection',
            value=mode)
        if mode == 1:  # manual entry
            self.category.Enable(True)
        elif self.category.IsEnabled():  # disable
            self.category.Enable(False)

        if mode == 2 and self.addRecord.IsChecked():  # no category
            self.addRecord.SetValue(False)

        self.digit.SetCategory()
        self.category.SetValue(
            UserSettings.Get(
                group='vdigit',
                key='category',
                subkey='value'))
Beispiel #7
0
    def _getSelectType(self):
        """Get type(s) to be selected

        Used by SelectLinesByBox() and SelectLineByPoint()
        """
        ftype = 0
        for feature in (('point', GV_POINT), ('line', GV_LINE),
                        ('centroid', GV_CENTROID), ('boundary', GV_BOUNDARY)):
            if UserSettings.Get(group='vdigit',
                                key='selectType',
                                subkey=[feature[0], 'enabled']):
                ftype |= feature[1]

        return ftype
Beispiel #8
0
    def __init__(self, parent, giface, link=False):
        """Dialog for bulk import of various vector data

        .. todo::
            split importing logic from gui code

        :param parent: parent window
        :param link: True for linking data otherwise importing data
        """
        self._giface = giface
        self.link = link

        self.layersData = []

        ImportDialog.__init__(self, parent, giface=giface, itype='ogr')

        self.list.SetValidator(
            LayersListValidator(
                condition='vector',
                callback=self._nameValidationFailed))

        if link:
            self.SetTitle(_("Link external vector data"))
        else:
            self.SetTitle(_("Import vector data"))

        self.dsnInput = GdalSelect(parent=self, panel=self.panel,
                                   ogr=True, link=link)
        self.dsnInput.AttachSettings()
        self.dsnInput.reloadDataRequired.connect(self.reload)

        if link:
            self.add.SetLabel(_("Add linked layers into layer tree"))
        else:
            self.add.SetLabel(_("Add imported layers into layer tree"))

        self.add.SetValue(
            UserSettings.Get(
                group='cmd',
                key='addNewLayer',
                subkey='enabled'))

        if link:
            self.btn_run.SetLabel(_("&Link"))
            self.btn_run.SetToolTip(_("Link selected layers"))
        else:
            self.btn_run.SetLabel(_("&Import"))
            self.btn_run.SetToolTip(_("Import selected layers"))

        self.doLayout()
Beispiel #9
0
 def OnGoTo(self, event):
     """Go to position"""
     try:
         e, n = self.GetValue().split(";")
         e, n = self.ReprojectENToMap(
             e, n, self.mapFrame.GetProperty("projection"))
         self.mapFrame.GetWindow().GoTo(e, n)
         self.widget.SetFocus()
     except ValueError:
         # FIXME: move this code to MapWindow/BufferedWindow/MapFrame
         region = self.mapFrame.GetMap().GetCurrentRegion()
         precision = int(
             UserSettings.Get(group="projection",
                              key="format",
                              subkey="precision"))
         format = UserSettings.Get(group="projection",
                                   key="format",
                                   subkey="ll")
         if self.mapFrame.GetMap(
         ).projinfo["proj"] == "ll" and format == "DMS":
             self.SetValue("%s" % utils.Deg2DMS(
                 region["center_easting"],
                 region["center_northing"],
                 precision=precision,
             ))
         else:
             self.SetValue("%.*f; %.*f" % (
                 precision,
                 region["center_easting"],
                 precision,
                 region["center_northing"],
             ))
     except SbException as e:
         # FIXME: this may be useless since statusbar update checks user
         # defined projection and this exception raises when user def proj
         # does not exists
         self.statusbar.SetStatusText(str(e), 0)
Beispiel #10
0
    def _createSymbologyPage(self, notebook):
        """!Create notebook page concerning symbology settings"""
        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
        notebook.AddPage(page = panel, text = _("Symbology"))

        sizer = wx.BoxSizer(wx.VERTICAL)
        
        flexSizer = wx.FlexGridSizer (cols = 3, hgap = 5, vgap = 5)
        flexSizer.AddGrowableCol(0)

        self.symbology = {}
        for label, key in self._symbologyData():
            textLabel = wx.StaticText(panel, wx.ID_ANY, label)
            color = csel.ColourSelect(panel, id = wx.ID_ANY,
                                      colour = UserSettings.Get(group = 'vdigit', key = 'symbol',
                                                                subkey = [key, 'color']),
                                      size = (40, 25))
            isEnabled = UserSettings.Get(group = 'vdigit', key = 'symbol',
                                         subkey = [key, 'enabled'])
            if isEnabled is not None:
                enabled = wx.CheckBox(panel, id = wx.ID_ANY, label = "")
                enabled.SetValue(isEnabled)
                self.symbology[key] = (enabled, color)
            else:
                enabled = (1, 1)
                self.symbology[key] = (None, color)
            
            flexSizer.Add(textLabel, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
            flexSizer.Add(enabled, proportion = 0, flag = wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
            flexSizer.Add(color, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
            color.SetName("GetColour")
        
        sizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 10)
        
        panel.SetSizer(sizer)
        
        return panel
Beispiel #11
0
    def SetVectorLinesDefaultProp(self, data):
        """Set default vector properties -- lines"""
        # width
        data['width'] = {
            'value':
            UserSettings.Get(group='nviz',
                             key='vector',
                             subkey=['lines', 'width'])
        }

        # color
        value = UserSettings.Get(group='nviz',
                                 key='vector',
                                 subkey=['lines', 'color'])
        color = str(value[0]) + ':' + str(value[1]) + ':' + str(value[2])
        data['color'] = {'value': color}

        # mode
        if UserSettings.Get(group='nviz',
                            key='vector',
                            subkey=['lines', 'flat']):
            type = 'flat'

        else:
            type = 'surface'

        data['mode'] = {}
        data['mode']['type'] = type
        data['mode']['update'] = None

        # height
        data['height'] = {
            'value':
            UserSettings.Get(group='nviz',
                             key='vector',
                             subkey=['lines', 'height'])
        }
        # thematic
        data['thematic'] = {
            'rgbcolumn':
            UserSettings.Get(group='nviz',
                             key='vector',
                             subkey=['lines', 'rgbcolumn']),
            'sizecolumn':
            UserSettings.Get(group='nviz',
                             key='vector',
                             subkey=['lines', 'sizecolumn']),
            'layer':
            1,
            'usecolor':
            False,
            'usewidth':
            False
        }
        if 'object' in data:
            for attrb in ('color', 'width', 'mode', 'height', 'thematic'):
                data[attrb]['update'] = None
Beispiel #12
0
def main():
    options, flags = gcore.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.globalvar import CheckWxVersion, MAP_WINDOW_SIZE
    from core.giface import StandaloneGrassInterface
    from core.settings import UserSettings
    from example.frame import ExampleMapDisplay

    if options["input"]:
        map_name = gcore.find_file(name=options["input"],
                                   element="cell")["fullname"]
        if not map_name:
            gcore.fatal(
                _("Raster map <{raster}> not found").format(
                    raster=options["input"]))

    # define display driver (avoid 'no graphics device selected' error at start up)
    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"

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

    # show main frame
    frame = wx.Frame(parent=None,
                     size=MAP_WINDOW_SIZE,
                     title=_("Example Tool - GRASSGIS"))
    frame = ExampleMapDisplay(
        parent=frame,
        giface=StandaloneGrassInterface(),
    )
    if options["input"]:
        frame.giface.WriteLog(
            _("Loading raster map <{raster}>...").format(raster=map_name))
        frame.SetLayer(map_name)

    frame.Show()
    app.MainLoop()
Beispiel #13
0
    def GetLabelsAndMaps(self):
        """Returns time labels and map names.
        """
        mapLists = []
        labelLists = []
        labelListSet = set()
        for dataset in self.timeseriesList:
            grassLabels, listOfMaps = self._getLabelsAndMaps(dataset)
            mapLists.append(listOfMaps)
            labelLists.append(tuple(grassLabels))
            labelListSet.update(grassLabels)
        # combine all timeLabels and fill missing maps with None
        # BUT this does not work properly if the datasets have
        # no temporal overlap! We would need to sample all datasets
        # by a temporary dataset, I don't know how it would work with point
        # data
        if self.temporalType == TemporalType.ABSOLUTE:
            timestamps = sorted(list(labelListSet), key=lambda x: x[0])
        else:
            timestamps = sorted(list(labelListSet), key=lambda x: x[0])

        newMapLists = []
        for mapList, labelList in zip(mapLists, labelLists):
            newMapList = [None] * len(timestamps)
            i = 0
            # compare start time
            while timestamps[i][0] != labelList[0][0]:  # compare
                i += 1
            newMapList[i:i + len(mapList)] = mapList
            newMapLists.append(newMapList)

        mapDict = {}
        for i, dataset in enumerate(self.timeseriesList):
            mapDict[dataset] = newMapLists[i]

        if self.temporalType == TemporalType.ABSOLUTE:
            # ('1996-01-01 00:00:00', '1997-01-01 00:00:00', 'year'),
            formatString = UserSettings.Get(group='animation',
                                            key='temporal',
                                            subkey='format')
            timestamps = [(datetime.datetime.strftime(st, formatString),
                           datetime.datetime.strftime(end, formatString)
                           if end is not None else None, unit)
                          for (st, end, unit) in timestamps]
        else:
            # ('15', '16', u'years'),
            timestamps = [(str(st), end if end is None else str(end), unit)
                          for st, end, unit in timestamps]
        return timestamps, mapDict
Beispiel #14
0
    def OnMapClickHandler(self, event):
        """Take coordinates from map window"""
        # TODO update snapping after input change
        if event == "unregistered":
            self.handlerRegistered = False
            return

        if not self.data:
            self.AddPoint()

        e, n = self.mapWin.GetLastEN()

        if self.snapping:

            # compute threshold
            snapTreshPix = int(
                UserSettings.Get(group="vnet",
                                 key="other",
                                 subkey="snap_tresh"))
            res = max(self.mapWin.Map.region["nsres"],
                      self.mapWin.Map.region["ewres"])
            snapTreshDist = snapTreshPix * res

            params, err_params, flags = self.an_params.GetParams()
            vectMap = params["input"]

            if "input" in err_params:
                msg = _("new point")

            coords = SnapToNode(e, n, snapTreshDist, vectMap)
            if coords:
                e = coords[0]
                n = coords[1]

                msg = "snapped to node"
            else:
                msg = _("new point")

        else:
            msg = _("new point")

        self.SetPointData(self.selected, {"topology": msg, "e": e, "n": n})

        self.pointsToDraw.GetItem(self.selected).SetCoords([e, n])

        if self.selected == len(self.data) - 1:
            self.SetSelected(0)
        else:
            self.SetSelected(self.GetSelected() + 1)
def main():
    """Sets the GRASS display driver
    """
    options, flags = gscript.parser()

    import wx
    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from photo2image.ip2i_manager import GCPWizard

    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'

    if options['group']:
        group = options['group']
    else:
        gscript.fatal(_("Please provide a group name to process"))
    
    if options['raster']:
        raster = options['raster']
    else:
        gscript.fatal(_("Please provide a raster map name to process"))

    if options['camera']:
        camera = options['camera']
    else:
        gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))

    if options['order']:
        order = options['order']
    else:
        gscript.fatal(_("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)"))

    if options['extension']:
        extension = options['extension']
    else:
        gscript.fatal(_("Please provive an output files extension (used by i.rectify)"))

    app = wx.App()

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(), group=group, 
            raster=raster, raster1=raster, camera=camera, order=order, extension=extension)
    app.MainLoop()
Beispiel #16
0
    def __init__(self, filename, expandAddons=True, message_handler=GError):

        self.menustyle = UserSettings.Get(
            group="appearance", key="menustyle", subkey="selection"
        )

        xmlTree = etree.parse(filename)
        if expandAddons:
            expAddons(xmlTree)
            for message in getToolboxMessages():
                message_handler(message)
            clearToolboxMessages()

        self.model = TreeModel(ModuleNode)
        self._createModel(xmlTree)
Beispiel #17
0
    def OnQuery(self, event):
        """Query selected lines/boundaries"""
        if self.action["desc"] == "queryLine":  # select previous action
            self.ToggleTool(self.addPoint, True)
            self.ToggleTool(self.additionalTools, False)
            self.OnAddPoint(event)
            return

        Debug.msg(
            2,
            "Digittoolbar.OnQuery(): %s"
            % UserSettings.Get(group="vdigit", key="query", subkey="selection"),
        )
        self.action = {"desc": "queryLine", "id": self.additionalTools}
        self.MapWindow.mouse["box"] = "box"
Beispiel #18
0
    def GetThreshold(self, type = 'snapping', value = None, units = None):
        """!Return threshold value in map units
        
        @param type snapping mode (node, vertex)
        @param value threshold to be set up
        @param units units (map, screen)

        @return threshold value
        """
        if value is None:
            value = UserSettings.Get(group = 'vdigit', key = type, subkey = 'value')
        
        if units is None:
            units = UserSettings.Get(group = 'vdigit', key = type, subkey = 'units')
        
        if value < 0:
            value = (self.region['nsres'] + self.region['ewres']) / 2.0
        
        if units == "screen pixels":
            # pixel -> cell
            res = max(self.region['nsres'], self.region['ewres'])
            return value * res
        
        return value
Beispiel #19
0
    def SetConstantDefaultProp(self):
        """Set default constant data properties"""
        data = dict()
        for key, value in six.iteritems(UserSettings.Get(group="nviz", key="constant")):
            data[key] = value
        color = (
            str(data["color"][0])
            + ":"
            + str(data["color"][1])
            + ":"
            + str(data["color"][2])
        )
        data["color"] = color

        return data
Beispiel #20
0
    def _initSettings(self):
        """Initialization of settings (if not already defined)"""
        # initializes default settings
        initSettings = [['res_style', 'line_width', 5],
                        ['res_style', 'line_color', (192, 0, 0)],
                        ['res_style', 'color_table', 'byr'],
                        ['res_style', 'invert_colors', False],
                        ['point_symbol', 'point_size', 10],
                        ['point_symbol', 'point_width', 2],
                        ['point_colors', "unused", (131, 139, 139)],
                        ['point_colors', "used1cat", (192, 0, 0)],
                        ['point_colors', "used2cat", (0, 0, 255)],
                        ['point_colors', "selected", (9, 249, 17)],
                        ['other', "snap_tresh", 10],
                        ['other', "max_hist_steps", 5]]

        for init in initSettings:
            UserSettings.ReadSettingsFile()
            UserSettings.Append(dict=UserSettings.userSettings,
                                group='vnet',
                                key=init[0],
                                subkey=init[1],
                                value=init[2],
                                overwrite=False)
Beispiel #21
0
def main():
    # allow immediate rendering
    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'

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = VDigitMapFrame(options['map'])
    frame.Show()

    app.MainLoop()
Beispiel #22
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from mapswipe.frame import SwipeMapFrame

    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"

    first = options["first"]
    second = options["second"]
    mode = options["mode"]

    for mapName in [first, second]:
        if mapName:
            gfile = gscript.find_file(name=mapName)
            if not gfile["name"]:
                gscript.fatal(_("Raster map <%s> not found") % mapName)

    app = wx.App()

    frame = SwipeMapFrame(
        parent=None,
        giface=StandaloneGrassInterface(),
        title=_("Map Swipe Tool - GRASS GIS"),
    )

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Beispiel #23
0
    def __init__(self, parent, data):
        """!Creates menubar"""
        wx.MenuBar.__init__(self)
        self.parent = parent
        self.menudata = data
        self.menucmd = dict()

        self.menustyle = UserSettings.Get(group='appearance',
                                          key='menustyle',
                                          subkey='selection')

        for eachMenuData in self.menudata.GetMenu():
            for eachHeading in eachMenuData:
                menuLabel = eachHeading[0]
                menuItems = eachHeading[1]
                self.Append(self._createMenu(menuItems), menuLabel)
Beispiel #24
0
    def _updateATM(self):
        """!Update open Attribute Table Manager
        
        @todo: use AddDataRow() instead
        """
        # update ATM
        digitVector = self.toolbar.GetLayer().GetName()

        for atm in self.lmgr.dialogs['atm']:
            atmVector = atm.GetVectorName()
            if atmVector == digitVector:
                layer = UserSettings.Get(group='vdigit',
                                         key="layer",
                                         subkey='value')
                # TODO: use AddDataRow instead
                atm.LoadData(layer)
Beispiel #25
0
    def GetRenderEnv(self, windres=False):
        env = os.environ.copy()
        env.update(self._render_env)
        # use external gisrc if defined
        if self.Map.gisrc:
            env['GISRC'] = self.Map.gisrc
        env['GRASS_REGION'] = self.Map.SetRegion(windres)
        env['GRASS_RENDER_WIDTH'] = str(self.Map.width)
        env['GRASS_RENDER_HEIGHT'] = str(self.Map.height)
        if UserSettings.Get(group='display', key='driver',
                            subkey='type') == 'png':
            env['GRASS_RENDER_IMMEDIATE'] = 'png'
        else:
            env['GRASS_RENDER_IMMEDIATE'] = 'cairo'

        return env
Beispiel #26
0
    def __init__(self, mapframe, statusbar, position=0):
        SbItem.__init__(self, mapframe, statusbar, position)
        self.name = 'render'

        self.widget = wx.CheckBox(parent=self.statusbar,
                                  id=wx.ID_ANY,
                                  label=_("Render"))

        self.widget.SetValue(
            UserSettings.Get(group='display',
                             key='autoRendering',
                             subkey='enabled'))
        self.widget.Hide()
        self.widget.SetToolTip(wx.ToolTip(_("Enable/disable auto-rendering")))

        self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleRender)
Beispiel #27
0
 def OnOK(self, event):
     """Checks if map exists and can be overwritten."""
     overwrite = UserSettings.Get(group = 'cmd', key = 'overwrite', subkey = 'enabled')
     vName = self.GetVectorName()
     res = grass.find_file(vName, element = 'vector')
     if res['fullname'] and overwrite is False:
         qdlg = wx.MessageDialog(parent = self,
                                     message = _("Vector map <%s> already exists."
                                                 " Do you want to overwrite it?" % vName) ,
                                     caption = _("Vector <%s> exists" % vName),
                                     style = wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION | wx.CENTRE)
         if qdlg.ShowModal() == wx.ID_YES:
             event.Skip()
         qdlg.Destroy()
     else:
         event.Skip()
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from core.utils import _
    from mapswipe.frame import SwipeMapFrame

    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'

    first = options['first']
    second = options['second']
    mode = options['mode']

    for mapName in [first, second]:
        if mapName:
            gfile = gscript.find_file(name=mapName)
            if not gfile['name']:
                gscript.fatal(_("Raster map <%s> not found") % mapName)

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

    frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface())

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Beispiel #29
0
    def __createWidgets(self):
        """!Create dialog widgets"""
        #
        # settings
        #
        self.settingsBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
                                        label = _(" Server settings "))

        self.serverText = wx.StaticText(parent = self.panel, id = wx.ID_ANY, label = _("Server:"))
        self.server  = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY)
        
        #
        # list of layers
        #
        self.layersBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
                                label=_(" List of layers "))

        self.list = LayersList(self.panel)
        self.list.LoadData()

        self.add = wx.CheckBox(parent=self.panel, id=wx.ID_ANY,
                               label=_("Add imported layers into layer tree"))
        self.add.SetValue(UserSettings.Get(group='cmd', key='addNewLayer', subkey='enabled'))
                
        #
        # buttons
        #
        # cancel
        self.btn_cancel = wx.Button(parent = self.panel, id = wx.ID_CANCEL)
        self.btn_cancel.SetToolTipString(_("Close dialog"))
        # connect
        self.btn_connect = wx.Button(parent = self.panel, id = wx.ID_ANY, label = _("&Connect"))
        self.btn_connect.SetToolTipString(_("Connect to the server"))
        self.btn_connect.SetDefault()
        if not self.server.GetValue():
            self.btn_connect.Enable(False)
        # import
        self.btn_import = wx.Button(parent = self.panel, id = wx.ID_OK, label = _("&Import"))
        self.btn_import.SetToolTipString(_("Import selected layers"))
        self.btn_import.Enable(False)
        
        #
        # bindings
        #
        self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
        self.btn_connect.Bind(wx.EVT_BUTTON, self.OnConnect)
        self.server.Bind(wx.EVT_TEXT, self.OnServer)
Beispiel #30
0
def GetUnicodeValue(value):
    """Get unicode value

    :param value: value to be recoded

    :return: unicode value
    """
    if isinstance(value, types.UnicodeType):
        return value

    enc = UserSettings.Get(group='atm', key='encoding', subkey='value')
    if not enc and 'GRASS_DB_ENCODING' in os.environ:
        enc = os.environ['GRASS_DB_ENCODING']
    else:
        enc = 'utf-8'  # assuming UTF-8

    return unicode(str(value), enc, errors='replace')