[GRASS-SVN] r45277 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 1 11:33:32 EST 2011


Author: martinl
Date: 2011-02-01 08:33:32 -0800 (Tue, 01 Feb 2011)
New Revision: 45277

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
Log:
wxGUI: import dialog more flags
(merge r45046 from trunk)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py	2011-02-01 16:09:49 UTC (rev 45276)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py	2011-02-01 16:33:32 UTC (rev 45277)
@@ -20,7 +20,7 @@
  - StaticWrapText
  - ImageSizeDialog
 
-(C) 2008-2010 by the GRASS Development Team
+(C) 2008-2011 by the GRASS Development Team
 
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
@@ -930,11 +930,12 @@
     
 class ImportDialog(wx.Dialog):
     """!Dialog for bulk import of various data (base class)"""
-    def __init__(self, parent, type,
+    def __init__(self, parent, itype,
                  id = wx.ID_ANY, title = _("Multiple import"),
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
-        self.parent = parent # GMFrame 
-        self.importType = type
+        self.parent = parent    # GMFrame 
+        self.importType = itype
+        self.options = dict()   # list of options
         
         self.commandId = -1  # id of running command
         
@@ -951,7 +952,33 @@
         #
         self.list = LayersList(self.panel)
         self.list.LoadData()
+
+        self.optionBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
+                                      label=_(" Options "))
         
+        cmd = self._getCommand()
+        task = menuform.GUI().ParseInterface(cmd = [cmd])
+        for f in task.get_options()['flags']:
+            name = f.get('name', '')
+            desc = f.get('label', '')
+            if not desc:
+                desc = f.get('description', '')
+            if not name and not desc:
+                continue
+            if cmd == 'r.in.gdal' and name not in ('o', 'e', 'l', 'k'):
+                continue
+            elif cmd == 'r.external' and name not in ('o', 'e', 'r', 'h', 'v'):
+                continue
+            elif cmd == 'v.in.ogr' and name not in ('c', 'z', 't', 'o', 'r', 'e', 'w'):
+                continue
+            elif cmd == 'v.external' and name not in ('b'):
+                continue
+            elif cmd == 'v.in.dxf' and name not in ('e', 't', 'b', 'f', 'i'):
+                continue
+            self.options[name] = wx.CheckBox(parent = self.panel, id = wx.ID_ANY,
+                                             label = desc)
+        
+        
         self.overwrite = wx.CheckBox(parent=self.panel, id=wx.ID_ANY,
                                      label=_("Allow output files to overwrite existing files"))
         self.overwrite.SetValue(UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'))
@@ -994,16 +1021,20 @@
         
         dialogSizer.Add(item=layerSizer, proportion=1,
                         flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
+
+        # options
+        optionSizer = wx.StaticBoxSizer(self.optionBox, wx.VERTICAL)
+        for key in self.options.keys():
+            optionSizer.Add(item=self.options[key], proportion=0)
+            
+        dialogSizer.Add(item=optionSizer, proportion=0,
+                        flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
         
-        if hasattr(self, "overrideCheck"):
-            dialogSizer.Add(item=self.overrideCheck, proportion=0,
-                            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
-        
         dialogSizer.Add(item=self.overwrite, proportion=0,
-                        flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
+                        flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
         
         dialogSizer.Add(item=self.add, proportion=0,
-                        flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
+                        flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
         
         #
         # buttons
@@ -1031,13 +1062,17 @@
         dialogSizer.Fit(self.panel)
         
         # auto-layout seems not work here - FIXME
-        size = wx.Size(globalvar.DIALOG_GSELECT_SIZE[0] + 175, 400)
+        size = wx.Size(globalvar.DIALOG_GSELECT_SIZE[0] + 225, 550)
         self.SetMinSize(size)
         self.SetSize((size.width, size.height + 100))
         width = self.GetSize()[0]
         self.list.SetColumnWidth(col=1, width=width/2 - 50)
         self.Layout()
-        
+
+    def _getCommand(self):
+        """!Get command"""
+        return ''
+    
     def OnCancel(self, event=None):
         """!Close dialog"""
         self.Close()
@@ -1096,13 +1131,13 @@
         self.ogr  = ogr
         
         if ogr:
-            ImportDialog.__init__(self, parent, type = 'ogr')
+            ImportDialog.__init__(self, parent, itype = 'ogr')
             if link:
                 self.SetTitle(_("Link external vector data"))
             else:
                 self.SetTitle(_("Import vector data"))
         else:
-            ImportDialog.__init__(self, parent, type = 'gdal') 
+            ImportDialog.__init__(self, parent, itype = 'gdal') 
             if link:
                 self.SetTitle(_("Link external raster data"))
             else:
@@ -1110,10 +1145,6 @@
        
         self.dsnInput = gselect.GdalSelect(parent = self, panel = self.panel, ogr = ogr)
 
-        if not link:
-            self.overrideCheck = wx.CheckBox(parent=self.panel, id=wx.ID_ANY,
-                                             label=_("Override projection (use location's projection)"))
-        
         if link:
             self.add.SetLabel(_("Add linked layers into layer tree"))
         else:
@@ -1180,8 +1211,9 @@
             if self.overwrite.IsChecked():
                 cmd.append('--overwrite')
             
-            if not self.link and self.overrideCheck.IsChecked():
-                cmd.append('-o')
+            for key in self.options.keys():
+                if self.options[key].IsChecked():
+                    cmd.append('-%s' % key)
             
             if UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'):
                 cmd.append('--overwrite')
@@ -1192,26 +1224,31 @@
         
         self.OnCancel()
 
-    def OnCmdDialog(self, event):
-        """!Show command dialog"""
+    def _getCommand(self):
+        """!Get command"""
         if self.link:
             if self.ogr:
-                name = 'v.external'
+                return 'v.external'
             else:
-                name = 'r.external'
+                return 'r.external'
         else:
             if self.ogr:
-                name = 'v.in.ogr'
+                return 'v.in.ogr'
             else:
-                name = 'r.in.gdal'
+                return 'r.in.gdal'
         
+        return ''
+    
+    def OnCmdDialog(self, event):
+        """!Show command dialog"""
+        name = self._getCommand()
         menuform.GUI().ParseCommand(cmd = [name],
                                     parentframe = self, modal = True)
         
 class DxfImportDialog(ImportDialog):
     """!Dialog for bulk import of DXF layers""" 
     def __init__(self, parent):
-        ImportDialog.__init__(self, parent, type = 'dxf',
+        ImportDialog.__init__(self, parent, itype = 'dxf',
                               title = _("Import DXF layers"))
         
         self.dsnInput = filebrowse.FileBrowseButton(parent=self.panel, id=wx.ID_ANY, 
@@ -1227,7 +1264,11 @@
         self.add.SetValue(UserSettings.Get(group='cmd', key='addNewLayer', subkey='enabled'))
         
         self.doLayout()
-        
+
+    def _getCommand(self):
+        """!Get command"""
+        return 'v.in.dxf'
+    
     def OnRun(self, event):
         """!Import/Link data (each layes as separate vector map)"""
         data = self.list.GetLayers()
@@ -1242,6 +1283,10 @@
                    'input=%s' % inputDxf,
                    'layers=%s' % layer,
                    'output=%s' % output]
+
+            for key in self.options.keys():
+                if self.options[key].IsChecked():
+                    cmd.append('-%s' % key)
             
             if self.overwrite.IsChecked() or \
                     UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'):



More information about the grass-commit mailing list