[GRASS-SVN] r48396 - in grass/trunk/gui: icons/grass wxpython
wxpython/gui_modules wxpython/icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 21 12:20:28 EDT 2011
Author: martinl
Date: 2011-09-21 09:20:28 -0700 (Wed, 21 Sep 2011)
New Revision: 48396
Added:
grass/trunk/gui/icons/grass/layer-export.png
Modified:
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/gui_modules/gselect.py
grass/trunk/gui/wxpython/gui_modules/utils.py
grass/trunk/gui/wxpython/icons/icon.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: implement GdalOutputDialog for v.external.out
Added: grass/trunk/gui/icons/grass/layer-export.png
===================================================================
(Binary files differ)
Property changes on: grass/trunk/gui/icons/grass/layer-export.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2011-09-21 12:11:14 UTC (rev 48395)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2011-09-21 16:20:28 UTC (rev 48396)
@@ -566,7 +566,7 @@
return message
def RunCommand(prog, flags = "", overwrite = False, quiet = False, verbose = False,
- parent = None, read = False, stdin = None, getErrorMsg = False, **kwargs):
+ parent = None, read = False, parse = None, stdin = None, getErrorMsg = False, **kwargs):
"""!Run GRASS command
@param prog program to run
@@ -574,6 +574,7 @@
@param overwrite, quiet, verbose flags
@param parent parent window for error messages
@param read fetch stdout
+ @param parse fn to parse stdout (e.g. grass.parse_key_val) or None
@param stdin stdin or None
@param getErrorMsg get error messages on failure
@param kwargs program parameters
@@ -632,6 +633,10 @@
Debug.msg(2, "gcmd.RunCommand(): return stdout\n'%s'" % stdout)
else:
Debug.msg(2, "gcmd.RunCommand(): return stdout = None")
+
+ if parse:
+ stdout = parse(stdout)
+
if not getErrorMsg:
return stdout
Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2011-09-21 12:11:14 UTC (rev 48395)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2011-09-21 16:20:28 UTC (rev 48396)
@@ -14,6 +14,7 @@
- AddMapLayersDialog
- ImportDialog
- GdalImportDialog
+ - GdalOutputDialog
- DxfImportDialog
- LayersList (used by MultiImport)
- SetOpacityDialog
@@ -1288,8 +1289,13 @@
pass
class GdalImportDialog(ImportDialog):
- """!Dialog for bulk import of various raster/vector data"""
def __init__(self, parent, ogr = False, link = False):
+ """!Dialog for bulk import of various raster/vector data
+
+ @param parent parent window
+ @param ogr True for OGR (vector) otherwise GDAL (raster)
+ @param link True for linking data otherwise importing data
+ """
self.link = link
self.ogr = ogr
@@ -1305,9 +1311,9 @@
self.SetTitle(_("Link external raster data"))
else:
self.SetTitle(_("Import raster data"))
-
+
self.dsnInput = gselect.GdalSelect(parent = self, panel = self.panel, ogr = ogr)
-
+
if link:
self.add.SetLabel(_("Add linked layers into layer tree"))
else:
@@ -1406,7 +1412,88 @@
"""!Show command dialog"""
name = self._getCommand()
menuform.GUI(parent = self, modal = True).ParseCommand(cmd = [name])
-
+
+class GdalOutputDialog(wx.Dialog):
+ def __init__(self, parent, id = wx.ID_ANY, ogr = False,
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, *kwargs):
+ """!Dialog for setting output format for rasters/vectors
+
+ @param parent parent window
+ @param id window id
+ @param ogr True for OGR (vector) otherwise GDAL (raster)
+ @param style window style
+ @param *kwargs other wx.Dialog's arguments
+ """
+ self.parent = parent # GMFrame
+ self.ogr = ogr
+ wx.Dialog.__init__(self, parent, id = id, style = style, *kwargs)
+ if self.ogr:
+ self.SetTitle(_("Define output format for vector data"))
+ else:
+ self.SetTitle(_("Define output format for raster data"))
+
+ self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
+
+ # buttons
+ self.btnCancel = wx.Button(parent = self.panel, id = wx.ID_CANCEL)
+ self.btnCancel.SetToolTipString(_("Close dialog"))
+ self.btnOk = wx.Button(parent = self.panel, id = wx.ID_OK)
+ self.btnOk.SetToolTipString(_("Set external format and close dialog"))
+ self.btnOk.SetDefault()
+ self.btnOk.Enable(False)
+
+ self.dsnInput = gselect.GdalSelect(parent = self, panel = self.panel,
+ ogr = ogr,
+ exclude = ['file', 'protocol'], dest = True)
+
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, self.btnCancel)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, self.btnOk)
+
+ self._layout()
+
+ def _layout(self):
+ dialogSizer = wx.BoxSizer(wx.VERTICAL)
+
+ dialogSizer.Add(item = self.dsnInput, proportion = 0,
+ flag = wx.EXPAND)
+
+ btnSizer = wx.StdDialogButtonSizer()
+ btnSizer.AddButton(self.btnOk)
+ btnSizer.AddButton(self.btnCancel)
+ btnSizer.Realize()
+
+ dialogSizer.Add(item = btnSizer, proportion = 0,
+ flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
+ border = 5)
+
+ self.panel.SetAutoLayout(True)
+ self.panel.SetSizer(dialogSizer)
+ dialogSizer.Fit(self.panel)
+
+ size = wx.Size(globalvar.DIALOG_GSELECT_SIZE[0] + 225, self.GetBestSize()[1])
+ self.SetMinSize(size)
+ self.SetSize((size.width, size.height))
+ self.Layout()
+
+ def OnCancel(self, event):
+ self.Destroy()
+
+ def OnOK(self, event):
+ if self.dsnInput.GetType() == 'native':
+ gcmd.RunCommand('v.external.out',
+ parent = self,
+ flags = 'r')
+ else:
+ dsn = self.dsnInput.GetDsn()
+ frmt = self.dsnInput.GetFormat()
+ options = self.dsnInput.GetOptions()
+
+ gcmd.RunCommand('v.external.out',
+ parent = self,
+ dsn = dsn, format = frmt,
+ options = options)
+ self.Close()
+
class DxfImportDialog(ImportDialog):
"""!Dialog for bulk import of DXF layers"""
def __init__(self, parent):
Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py 2011-09-21 12:11:14 UTC (rev 48395)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py 2011-09-21 16:20:28 UTC (rev 48396)
@@ -970,7 +970,7 @@
class FormatSelect(wx.Choice):
def __init__(self, parent, ogr = False,
- sourceType = None, id = wx.ID_ANY, size = globalvar.DIALOG_COMBOBOX_SIZE,
+ sourceType = None, id = wx.ID_ANY, size = globalvar.DIALOG_SPIN_SIZE,
**kwargs):
"""!Widget for selecting external (GDAL/OGR) format
@@ -1064,30 +1064,42 @@
return ''
class GdalSelect(wx.Panel):
- def __init__(self, parent, panel, ogr = False,
+ def __init__(self, parent, panel, ogr = False, dest = False,
default = 'file', exclude = [], envHandler = None):
"""!Widget for selecting GDAL/OGR datasource, format
@param parent parent window
@param ogr use OGR selector instead of GDAL
+ @param dest True for output (destination)
+ @param default deafult type (ignored when dest == True)
+ @param exclude list of types to be excluded
"""
self.parent = parent
self.ogr = ogr
+ self.dest = dest
wx.Panel.__init__(self, parent = panel, id = wx.ID_ANY)
- self.settingsBox = wx.StaticBox(parent = self, id=wx.ID_ANY,
- label=" %s " % _("Settings"))
+ self.settingsBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Settings"))
- self.inputBox = wx.StaticBox(parent = self, id=wx.ID_ANY,
- label=" %s " % _("Source"))
+ self.inputBox = wx.StaticBox(parent = self, id = wx.ID_ANY)
+ if dest:
+ self.inputBox.SetLabel(" %s " % _("Output settings"))
+ else:
+ self.inputBox.SetLabel(" %s " % _("Source settings"))
# source type
sources = list()
self.sourceMap = { 'file' : -1,
'dir' : -1,
'db' : -1,
- 'pro' : -1 }
+ 'pro' : -1,
+ 'native' : -1 }
idx = 0
+ if dest:
+ sources.append(_("Native"))
+ self.sourceMap['native'] = idx
+ idx += 1
if 'file' not in exclude:
sources.append(_("File"))
self.sourceMap['file'] = idx
@@ -1117,9 +1129,13 @@
self.btnSettings.Bind(wx.EVT_BUTTON, self.OnSettingsSave)
self.source = wx.RadioBox(parent = self, id = wx.ID_ANY,
- label = _('Source type'),
style = wx.RA_SPECIFY_COLS,
choices = sources)
+ if dest:
+ self.source.SetLabel(" %s " % _('Output type'))
+ else:
+ self.source.SetLabel(" %s " % _('Source type'))
+
self.source.SetSelection(0)
self.source.Bind(wx.EVT_RADIOBOX, self.OnSetType)
@@ -1187,24 +1203,35 @@
fType = 'gdal'
self.input = { 'file' : [_("File:"),
dsnFile,
- utils.GetFormats()[fType]['file']],
- 'dir' : [_("Directory:"),
+ utils.GetFormats(writableOnly = dest)[fType]['file']],
+ 'dir' : [_("Name:"),
dsnDir,
- utils.GetFormats()[fType]['file']],
- 'db' : [_("Database:"),
- dsnDbFile,
- utils.GetFormats()[fType]['database']],
+ utils.GetFormats(writableOnly = dest)[fType]['file']],
+ 'db' : [_("Name:"),
+ dsnDbText,
+ utils.GetFormats(writableOnly = dest)[fType]['database']],
'pro' : [_("Protocol:"),
dsnPro,
- utils.GetFormats()[fType]['protocol']],
+ utils.GetFormats(writableOnly = dest)[fType]['protocol']],
'db-win' : { 'file' : dsnDbFile,
'text' : dsnDbText,
'choice' : dsnDbChoice },
+ 'native' : [_("Name:"), dsnDir, ''],
}
- self.dsnType = default
- self.input[self.dsnType][1].Show()
- self.format.SetItems(self.input[self.dsnType][2])
+ if self.dest:
+ current = gcmd.RunCommand('v.external.out',
+ parent = self,
+ read = True, parse = grass.parse_key_val,
+ flags = 'g')
+ if current['format'] == 'native':
+ self.dsnType = 'native'
+ elif current['format'] in utils.GetFormats()['ogr']['database']:
+ self.dsnType = 'db'
+ else:
+ self.dsnType = 'dir'
+ else:
+ self.dsnType = default
self.dsnText = wx.StaticText(parent = self, id = wx.ID_ANY,
label = self.input[self.dsnType][0],
@@ -1213,12 +1240,23 @@
label = _("Extension:"))
self.extensionText.Hide()
+ self.creationOpt = wx.TextCtrl(parent = self, id = wx.ID_ANY)
+ if not self.dest:
+ self.creationOpt.Hide()
+
self._layout()
-
- if not ogr:
- self.OnSetFormat(event = None, format = 'GeoTIFF')
+
+ self.OnSetType(event = None, sel = self.sourceMap[self.dsnType])
+ if self.dest:
+ if current['format'] != 'native':
+ self.OnSetFormat(event = None, format = current['format'])
+ self.OnSetDsn(event = None, path = current['dsn'])
+ self.creationOpt.SetValue(current['options'])
else:
- self.OnSetFormat(event = None, format = 'ESRI Shapefile')
+ if not ogr:
+ self.OnSetFormat(event = None, format = 'GeoTIFF')
+ else:
+ self.OnSetFormat(event = None, format = 'ESRI Shapefile')
def _layout(self):
"""!Layout"""
@@ -1240,33 +1278,44 @@
inputSizer = wx.StaticBoxSizer(self.inputBox, wx.HORIZONTAL)
self.dsnSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
- self.dsnSizer.AddGrowableRow(1)
+ #self.dsnSizer.AddGrowableRow(0)
self.dsnSizer.AddGrowableCol(3)
- self.dsnSizer.Add(item=self.dsnText,
- flag=wx.ALIGN_CENTER_VERTICAL,
- pos = (0, 0))
- self.dsnSizer.Add(item=self.input[self.dsnType][1],
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1), span = (1, 3))
-
+ row = 0
self.dsnSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
label = _("Format:")),
flag = wx.ALIGN_CENTER_VERTICAL,
- pos = (1, 0))
+ pos = (row, 0))
self.dsnSizer.Add(item=self.format,
flag = wx.ALIGN_CENTER_VERTICAL,
- pos = (1, 1))
+ pos = (row, 1))
self.dsnSizer.Add(item = self.extensionText,
flag=wx.ALIGN_CENTER_VERTICAL,
- pos = (1, 2))
+ pos = (row, 2))
self.dsnSizer.Add(item=self.extension,
flag = wx.ALIGN_CENTER_VERTICAL,
- pos = (1, 3))
+ pos = (row, 3))
+ row += 1
+ self.dsnSizer.Add(item = self.dsnText,
+ flag = wx.ALIGN_CENTER_VERTICAL,
+ pos = (row, 0))
+ self.dsnSizer.Add(item = self.input[self.dsnType][1],
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos = (row, 1), span = (1, 3))
+ row += 1
+ if self.creationOpt.IsShown():
+ self.dsnSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _("Creation options:")),
+ flag = wx.ALIGN_CENTER_VERTICAL,
+ pos = (row, 0))
+ self.dsnSizer.Add(item = self.creationOpt,
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos = (row, 1), span = (1, 3))
+ row += 1
- inputSizer.Add(item=self.dsnSizer, proportion=1,
- flag=wx.EXPAND | wx.ALL)
-
+ inputSizer.Add(item=self.dsnSizer, proportion = 1,
+ flag=wx.EXPAND | wx.BOTTOM, border = 10)
+
mainSizer.Add(item=settingsSizer, proportion=0,
flag=wx.ALL | wx.EXPAND, border=5)
mainSizer.Add(item=self.source, proportion=0,
@@ -1293,12 +1342,13 @@
name = event.GetString()
if name not in self._settings:
gcmd.GError(parent = self,
- message = _("Settings named '%s' not found") % name)
+ message = _("Settings <%s> not found") % name)
return
data = self._settings[name]
self.OnSetType(event = None, sel = self.sourceMap[data[0]])
self.OnSetFormat(event = None, format = data[2])
self.OnSetDsn(event = None, path = data[1])
+ self.creationOpt.SetValue(data[3])
def OnSettingsSave(self, event):
"""!Save settings"""
@@ -1317,7 +1367,7 @@
try:
fd = open(self.settingsFile, 'a')
fd.write(name + ';' + self.dsnType + ';' +
- self._getDsn() + ';' +
+ self.GetDsn() + ';' +
self.format.GetStringSelection())
fd.write('\n')
except IOError:
@@ -1348,8 +1398,12 @@
fd = open(self.settingsFile, 'r')
for line in fd.readlines():
try:
- name, ftype, dsn, format = line.rstrip('\n').split(';')
- data[name] = (ftype, dsn, format)
+ lineData = line.rstrip('\n').split(';')
+ if len(lineData) > 4:
+ # type, dsn, format, options
+ data[lineData[0]] = (lineData[1], lineData[2], lineData[3], lineData[4])
+ else:
+ data[lineData[0]] = (lineData[1], lineData[2], lineData[3], '')
except ValueError:
pass
except IOError:
@@ -1365,10 +1419,11 @@
sel = event.GetSelection()
else:
self.source.SetSelection(sel)
+ win = self.input[self.dsnType][1]
+ if win:
+ self.dsnSizer.Remove(win)
+ win.Hide()
- win = self.input[self.dsnType][1]
- self.dsnSizer.Remove(win)
- win.Hide()
if sel == self.sourceMap['file']: # file
self.dsnType = 'file'
format = self.input[self.dsnType][2][0]
@@ -1392,39 +1447,46 @@
elif sel == self.sourceMap['dir']: # directory
self.dsnType = 'dir'
- elif sel == self.sourceMap['db']: # database
+ elif sel == self.sourceMap['db']: # database
self.dsnType = 'db'
elif sel == self.sourceMap['pro']: # protocol
self.dsnType = 'pro'
+ elif sel == self.sourceMap['native']:
+ self.dsnType = 'native'
- self.dsnText.SetLabel(self.input[self.dsnType][0])
- if self.parent.GetName() == 'MultiImportDialog':
- self.parent.list.DeleteAllItems()
- self.format.SetItems(self.input[self.dsnType][2])
+ if self.dsnType == 'db':
+ self.input[self.dsnType][1] = self.input['db-win']['text']
+ win = self.input[self.dsnType][1]
+
+ self.dsnSizer.Add(item = self.input[self.dsnType][1],
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos = (1, 1), span = (1, 3))
+ win.SetValue('')
+ win.Show()
if sel in (self.sourceMap['file'],
self.sourceMap['dir']):
- win = self.input[self.dsnType][1]
- self.dsnSizer.Add(item=self.input[self.dsnType][1],
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1))
- win.SetValue('')
- win.Show()
-
if not self.ogr:
self.OnSetFormat(event = None, format = 'GeoTIFF')
else:
self.OnSetFormat(event = None, format = 'ESRI Shapefile')
+
+ if sel == self.sourceMap['native']: # native
+ win.Enable(False)
+ self.format.Enable(False)
+ self.creationOpt.Enable(False)
+ self.parent.btnOk.Enable(True)
else:
- if sel == self.sourceMap['pro']:
- win = self.input[self.dsnType][1]
- self.dsnSizer.Add(item=self.input[self.dsnType][1],
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1))
- win.SetValue('')
- win.Show()
+ if not self.format.IsEnabled():
+ win.Enable(True)
+ self.format.Enable(True)
+ self.creationOpt.Enable(True)
+ self.dsnText.SetLabel(self.input[self.dsnType][0])
+ self.format.SetItems(self.input[self.dsnType][2])
+ if self.parent.GetName() == 'MultiImportDialog':
+ self.parent.list.DeleteAllItems()
- if sel == self.sourceMap['dir']:
+ if sel == self.sourceMap['dir'] and not self.dest:
if not self.extension.IsShown():
self.extensionText.Show()
self.extension.Show()
@@ -1432,10 +1494,10 @@
if self.extension.IsShown():
self.extensionText.Hide()
self.extension.Hide()
-
+
self.dsnSizer.Layout()
- def _getDsn(self):
+ def GetDsn(self):
"""!Get datasource name"""
if self.format.GetStringSelection() == 'PostgreSQL':
return 'PG:dbname=%s' % self.input[self.dsnType][1].GetStringSelection()
@@ -1456,18 +1518,23 @@
break
else:
self.input[self.dsnType][1].SetValue(path)
-
+
if not path:
- return
-
- self._reloadLayers()
+ if self.dest:
+ self.parent.btnOk.Enable(False)
+ return
+ if self.dest:
+ self.parent.btnOk.Enable(True)
+ else:
+ self._reloadLayers()
+
if event:
event.Skip()
def _reloadLayers(self):
"""!Reload list of layers"""
- dsn = self._getDsn()
+ dsn = self.GetDsn()
if not dsn:
return
@@ -1521,8 +1588,9 @@
def OnSetExtension(self, event):
"""!Extension changed"""
- # reload layers
- self._reloadLayers()
+ if not self.dest:
+ # reload layers
+ self._reloadLayers()
def OnSetFormat(self, event, format = None):
"""!Format changed"""
@@ -1582,24 +1650,27 @@
if dbname:
db.append(dbname)
win.SetItems(db)
+ if self.dest and win.GetStringSelection():
+ self.parent.btnOk.Enable(True)
else:
win = self.input['db-win']['text']
else:
win = self.input['db-win']['text']
-
+
self.input[self.dsnType][1] = win
if not win.IsShown():
win.Show()
self.dsnSizer.Add(item = self.input[self.dsnType][1],
flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (0, 1), span = (1, 3))
+ pos = (1, 1), span = (1, 3))
self.dsnSizer.Layout()
# update extension
self.extension.SetValue(self.GetFormatExt())
- # reload layers
- self._reloadLayers()
+ if not self.dest:
+ # reload layers
+ self._reloadLayers()
def GetType(self):
"""!Get source type"""
@@ -1622,10 +1693,21 @@
return win
+ def GetFormat(self):
+ """!Get format as string"""
+ return self.format.GetStringSelection().replace(' ', '_')
+
def GetFormatExt(self):
"""!Get format extension"""
return self.format.GetExtension(self.format.GetStringSelection())
+ def GetOptions(self):
+ """!Get creation options"""
+ if not self.creationOpt.IsShown():
+ return ''
+
+ return self.creationOpt.GetValue()
+
class ProjSelect(wx.ComboBox):
"""!Widget for selecting input raster/vector map used by
r.proj/v.proj modules."""
Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py 2011-09-21 12:11:14 UTC (rev 48395)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py 2011-09-21 16:20:28 UTC (rev 48396)
@@ -19,6 +19,7 @@
import glob
import locale
import shlex
+import re
import globalvar
sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
@@ -52,7 +53,7 @@
@return Path to file name (string) or None
"""
import gcmd
-
+
ret = gcmd.RunCommand('g.tempfile',
read = True,
pid = os.getpid())
@@ -689,7 +690,7 @@
quiet = True,
flags = 'f')
- return _parseFormats(ret)
+ return _parseFormats(ret), _parseFormats(ret, writableOnly = True)
def _getOGRFormats():
"""!Get dictionary of avaialble OGR drivers"""
@@ -697,9 +698,9 @@
quiet = True,
flags = 'f')
- return _parseFormats(ret)
+ return _parseFormats(ret), _parseFormats(ret, writableOnly = True)
-def _parseFormats(output):
+def _parseFormats(output, writableOnly = False):
"""!Parse r.in.gdal/v.in.ogr -f output"""
formats = { 'file' : list(),
'database' : list(),
@@ -709,22 +710,30 @@
if not output:
return formats
+ patt = None
+ if writableOnly:
+ patt = re.compile('\(rw\+?\)$', re.IGNORECASE)
+
for line in output.splitlines():
- format = line.strip().rsplit(':', -1)[1].strip()
- if format in ('Memory', 'Virtual Raster', 'In Memory Raster'):
+ key, name = map(lambda x: x.strip(), line.strip().rsplit(':', -1))
+
+ if writableOnly and not patt.search(key):
continue
- if format in ('PostgreSQL', 'SQLite',
- 'ODBC', 'ESRI Personal GeoDatabase',
- 'Rasterlite',
- 'PostGIS WKT Raster driver'):
- formats['database'].append(format)
- elif format in ('GeoJSON',
- 'OGC Web Coverage Service',
- 'OGC Web Map Service',
- 'HTTP Fetching Wrapper'):
- formats['protocol'].append(format)
+
+ if name in ('Memory', 'Virtual Raster', 'In Memory Raster'):
+ continue
+ if name in ('PostgreSQL', 'SQLite',
+ 'ODBC', 'ESRI Personal GeoDatabase',
+ 'Rasterlite',
+ 'PostGIS WKT Raster driver'):
+ formats['database'].append(name)
+ elif name in ('GeoJSON',
+ 'OGC Web Coverage Service',
+ 'OGC Web Map Service',
+ 'HTTP Fetching Wrapper'):
+ formats['protocol'].append(name)
else:
- formats['file'].append(format)
+ formats['file'].append(name)
for items in formats.itervalues():
items.sort()
@@ -733,16 +742,27 @@
formats = None
-def GetFormats():
+def GetFormats(writableOnly = False):
"""!Get GDAL/OGR formats"""
global formats
if not formats:
+ gdalAll, gdalWritable = _getGDALFormats()
+ ogrAll, ogrWritable = _getOGRFormats()
formats = {
- 'gdal' : _getGDALFormats(),
- 'ogr' : _getOGRFormats()
+ 'all' : {
+ 'gdal' : gdalAll,
+ 'ogr' : ogrAll,
+ },
+ 'writable' : {
+ 'gdal' : gdalWritable,
+ 'ogr' : ogrWritable,
+ },
}
- return formats
+ if writableOnly:
+ return formats['writable']
+
+ return formats['all']
def GetSettingsPath():
"""!Get full path to the settings directory
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2011-09-21 12:11:14 UTC (rev 48395)
+++ grass/trunk/gui/wxpython/icons/icon.py 2011-09-21 16:20:28 UTC (rev 48396)
@@ -181,10 +181,14 @@
label = _('Import raster data')),
'rastLink' : MetaIcon(img = iconSet.get('layer-import', wx.ART_ERROR),
label = _('Link external raster data')),
+ 'rastOut' : MetaIcon(img = iconSet.get('layer-export', wx.ART_ERROR),
+ label = _('Set raster output format')),
'vectImport' : MetaIcon(img = iconSet.get('layer-import', wx.ART_ERROR),
label = _('Import vector data')),
'vectLink' : MetaIcon(img = iconSet.get('layer-import', wx.ART_ERROR),
label = _('Link external vector data')),
+ 'vectOut' : MetaIcon(img = iconSet.get('layer-export', wx.ART_ERROR),
+ label = _('Set vector output format')),
'addRast' : MetaIcon(img = iconSet.get('layer-raster-add', wx.ART_ERROR),
label = _('Add raster map layer (Ctrl+Shift+R)')),
'rastMisc' : MetaIcon(img = iconSet.get('layer-raster-more', wx.ART_ERROR),
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2011-09-21 12:11:14 UTC (rev 48395)
+++ grass/trunk/gui/wxpython/wxgui.py 2011-09-21 16:20:28 UTC (rev 48396)
@@ -697,9 +697,11 @@
"""
self._popupMenu((('rastImport', self.OnImportGdalLayers),
('rastLink', self.OnLinkGdalLayers),
+ ('rastOut', self.OnRasterOutputFormat),
(None, None),
('vectImport', self.OnImportOgrLayers),
- ('vectLink', self.OnLinkOgrLayers)))
+ ('vectLink', self.OnLinkOgrLayers),
+ ('vectOut', self.OnVectorOutputFormat)))
def OnWorkspaceNew(self, event = None):
"""!Create new workspace file
@@ -1128,7 +1130,17 @@
win = vclean.VectorCleaningFrame(parent = self, cmd = cmd[0])
win.CentreOnScreen()
win.Show()
-
+
+ def OnRasterOutputFormat(self, event):
+ """!Set raster output format handler"""
+ self.OnMenuCmd(cmd = ['r.external.out'])
+
+ def OnVectorOutputFormat(self, event):
+ """!Set vector output format handler"""
+ dlg = gdialogs.GdalOutputDialog(parent = self, ogr = True)
+ dlg.CentreOnScreen()
+ dlg.Show()
+
def OnImportDxfFile(self, event, cmd = None):
"""!Convert multiple DXF layers to GRASS vector map layers"""
dlg = gdialogs.DxfImportDialog(parent = self)
More information about the grass-commit
mailing list