[GRASS-SVN] r37894 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 15 15:27:48 EDT 2009
Author: martinl
Date: 2009-06-15 15:27:48 -0400 (Mon, 15 Jun 2009)
New Revision: 37894
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
support external data sources in the wxPython-GUI (trac #643)
(merge from trunk, r37893)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2009-06-15 19:24:43 UTC (rev 37893)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2009-06-15 19:27:48 UTC (rev 37894)
@@ -825,11 +825,13 @@
class MultiImportDialog(wx.Dialog):
"""!Import dxf layers"""
def __init__(self, parent, type,
- id=wx.ID_ANY, title=_("Multiple import"),
+ id=wx.ID_ANY, title=_("Multiple import"),
+ link = False,
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
self.parent = parent # GMFrame
self.inputType = type
+ self.link = link # Link or import data (only for GDAL/OGR)
wx.Dialog.__init__(self, parent, id, title, style=style)
@@ -839,7 +841,7 @@
self.inputTitle = _("Input DXF file")
else:
self.inputTitle = _("Input directory")
-
+
self.inputBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
label=" %s " % self.inputTitle)
self.layerBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
@@ -881,8 +883,11 @@
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 = wx.CheckBox(parent=self.panel, id=wx.ID_ANY)
+ 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'))
#
@@ -893,8 +898,12 @@
self.btn_cancel.SetToolTipString(_("Close dialog"))
self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
# run
- self.btn_run = wx.Button(parent=self.panel, id=wx.ID_OK, label= _("&Import"))
- self.btn_run.SetToolTipString(_("Import selected layers"))
+ if link:
+ self.btn_run = wx.Button(parent=self.panel, id=wx.ID_OK, label= _("&Link"))
+ self.btn_run.SetToolTipString(_("Link selected layers"))
+ else:
+ self.btn_run = wx.Button(parent=self.panel, id=wx.ID_OK, label= _("&Import"))
+ self.btn_run.SetToolTipString(_("Import selected layers"))
self.btn_run.SetDefault()
self.btn_run.Enable(False)
self.btn_run.Bind(wx.EVT_BUTTON, self.OnRun)
@@ -974,7 +983,7 @@
self.Close()
def OnRun(self, event):
- """!Import data (each layes as separate vector map)"""
+ """!Import/Link data (each layes as separate vector map)"""
data = self.list.GetLayers()
# hide dialog
@@ -987,13 +996,25 @@
'layers=%s' % layer,
'output=%s' % output]
elif self.inputType == 'ogr':
- cmd = ['v.in.ogr',
- 'dsn=%s' % (os.path.join(self.input.GetValue(), layer)),
- 'output=%s' % output]
- else:
- cmd = ['r.in.gdal', '-o', # override projection by default
- 'input=%s' % (os.path.join(self.input.GetValue(), layer)),
- 'output=%s' % output]
+ if self.link:
+ cmd = ['v.external',
+ 'dsn=%s' % os.path.join(self.input.GetValue()),
+ 'output=%s' % output,
+ 'layer=%s' % layer.rstrip('.' + self.format.GetValue())
+ ]
+ else:
+ cmd = ['v.in.ogr',
+ 'dsn=%s' % (os.path.join(self.input.GetValue(), layer)),
+ 'output=%s' % output]
+ else: # gdal
+ if self.link:
+ cmd = ['r.external', '-o', # override projection by default
+ 'input=%s' % (os.path.join(self.input.GetValue(), layer)),
+ 'output=%s' % output]
+ else:
+ cmd = ['r.in.gdal', '-o', # override projection by default
+ 'input=%s' % (os.path.join(self.input.GetValue(), layer)),
+ 'output=%s' % output]
if UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'):
cmd.append('--overwrite')
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2009-06-15 19:24:43 UTC (rev 37893)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2009-06-15 19:27:48 UTC (rev 37894)
@@ -1027,17 +1027,31 @@
dlg.ShowModal()
def OnImportGdalLayers(self, event):
- """!Convert multiple GDAL layers to GRASS vector map layers"""
+ """!Convert multiple GDAL layers to GRASS raster map layers"""
dlg = gdialogs.MultiImportDialog(parent=self, type='gdal',
title=_("Import GDAL layers"))
dlg.ShowModal()
+ def OnLinkGdalLayers(self, event):
+ """!Link multiple GDAL layers to GRASS raster map layers"""
+ dlg = gdialogs.MultiImportDialog(parent=self, type='gdal',
+ title=_("Link GDAL layers"),
+ link = True)
+ dlg.ShowModal()
+
def OnImportOgrLayers(self, event):
"""!Convert multiple OGR layers to GRASS vector map layers"""
dlg = gdialogs.MultiImportDialog(parent=self, type='ogr',
title=_("Import OGR layers"))
dlg.ShowModal()
+ def OnLinkOgrLayers(self, event):
+ """!Links multiple OGR layers to GRASS vector map layers"""
+ dlg = gdialogs.MultiImportDialog(parent=self, type='ogr',
+ title=_("Link OGR layers"),
+ link = True)
+ dlg.ShowModal()
+
def OnImportWMS(self, event):
"""!Import data from OGC WMS server"""
dlg = ogc_services.WMSDialog(parent = self, service = 'wms')
Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml 2009-06-15 19:24:43 UTC (rev 37893)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml 2009-06-15 19:27:48 UTC (rev 37894)
@@ -830,6 +830,11 @@
<handler>self.OnMenuCmd</handler>
<command>r.external</command>
</menuitem>
+ <menuitem>
+ <label>Multiple link to GDAL</label>
+ <help>Link GDAL supported raster files to a binary raster map layers.</help>
+ <handler>self.OnLinkGdalLayers</handler>
+ </menuitem>
<separator />
<menuitem>
<label>Reproject raster</label>
@@ -1797,6 +1802,11 @@
<handler>self.OnMenuCmd</handler>
<command>v.external</command>
</menuitem>
+ <menuitem>
+ <label>Multiple link to OGR</label>
+ <help>Creates a new vectors as a read-only link to OGR layers.</help>
+ <handler>self.OnLinkOgrLayers</handler>
+ </menuitem>
<separator />
<menuitem>
<label>Create labels</label>
More information about the grass-commit
mailing list