[GRASS-SVN] r37895 - in grass/branches/releasebranch_6_4/gui/wxpython: . gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 15 15:31:54 EDT 2009


Author: martinl
Date: 2009-06-15 15:31:54 -0400 (Mon, 15 Jun 2009)
New Revision: 37895

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
   grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
   grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml
Log:
support external data sources in the wxPython-GUI (trac #643)
       (merge from trunk, r37893)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py	2009-06-15 19:27:48 UTC (rev 37894)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py	2009-06-15 19:31:54 UTC (rev 37895)
@@ -803,11 +803,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)
 
@@ -817,7 +819,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,
@@ -859,8 +861,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'))
 
         #
@@ -871,8 +876,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)
@@ -952,7 +961,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
@@ -965,13 +974,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/releasebranch_6_4/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py	2009-06-15 19:27:48 UTC (rev 37894)
+++ grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py	2009-06-15 19:31:54 UTC (rev 37895)
@@ -1131,16 +1131,30 @@
         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 OnShowAttributeTable(self, event):
         """

Modified: grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml	2009-06-15 19:27:48 UTC (rev 37894)
+++ grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml	2009-06-15 19:31:54 UTC (rev 37895)
@@ -742,6 +742,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>
@@ -1593,6 +1598,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