[GRASS-SVN] r54399 - grass/trunk/gui/wxpython/iclass

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 25 08:32:56 PST 2012


Author: martinl
Date: 2012-12-25 08:32:55 -0800 (Tue, 25 Dec 2012)
New Revision: 54399

Modified:
   grass/trunk/gui/wxpython/iclass/frame.py
   grass/trunk/gui/wxpython/iclass/g.gui.iclass.py
Log:
g.gui.iclass: add parameters - 'group' and 'map'


Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py	2012-12-25 12:02:09 UTC (rev 54398)
+++ grass/trunk/gui/wxpython/iclass/frame.py	2012-12-25 16:32:55 UTC (rev 54399)
@@ -45,7 +45,7 @@
 from vdigit.toolbars    import VDigitToolbar
 from gui_core.mapdisp   import DoubleMapFrame
 from core.render        import Map, MapLayer
-from core.gcmd          import RunCommand, GMessage
+from core.gcmd          import RunCommand, GMessage, GError
 from gui_core.dialogs   import SetOpacityDialog
 from dbmgr.vinfo        import VectorDBInfo
 import grass.script as grass
@@ -422,12 +422,17 @@
         """!Add imagery group"""
         dlg = IClassGroupDialog(self, group = self.group)
         if dlg.ShowModal() == wx.ID_OK:
-            group = grass.find_file(name = dlg.GetGroup(), element = 'group')
-            if group['name']:
-                self.group = group['name']
-                
+            self.SetGroup(dlg.GetGroup())
         dlg.Destroy()
         
+    def SetGroup(self, name):
+        """!Set immagery group"""
+        group = grass.find_file(name = name, element = 'group')
+        if group['name']:
+            self.group = group['name']
+        else:
+            GError(_("Group <%s> not found") % name, parent = self)
+    
     def OnImportAreas(self, event):
         """!Import training areas"""
         # check if we have any changes

Modified: grass/trunk/gui/wxpython/iclass/g.gui.iclass.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/g.gui.iclass.py	2012-12-25 12:02:09 UTC (rev 54398)
+++ grass/trunk/gui/wxpython/iclass/g.gui.iclass.py	2012-12-25 16:32:55 UTC (rev 54399)
@@ -28,6 +28,13 @@
 #% keywords: classification
 #% keywords: signatures
 #%end
+#%option G_OPT_I_GROUP
+#% required: no
+#%end
+#%option G_OPT_R_MAP
+#% description: Name of raster map to load
+#% required: no
+#%end
 
 import os
 import sys
@@ -45,6 +52,15 @@
 from iclass.frame   import IClassMapFrame
 
 def main():
+    if options['group']:
+        group_name = grass.find_file(name = options['group'], element = 'group')['name']
+        if not group_name:
+            grass.fatal(_("Group <%s> not found") % options['group'])
+    if options['map']:
+        map_name = grass.find_file(name = options['map'], element = 'cell')['fullname']
+        if not map_name:
+            grass.fatal(_("Raster map <%s> not found") % options['map'])
+    
     # define display driver
     driver = UserSettings.Get(group = 'display', key = 'driver', subkey = 'type')
     if driver == 'png':
@@ -57,12 +73,20 @@
     wx.InitAllImageHandlers()
     
     # show main frame
-    frame = IClassMapFrame(parent = None, giface = StandaloneGrassInterface())
+    giface = StandaloneGrassInterface()
+    frame = IClassMapFrame(parent = None, giface = giface)
+    if group_name:
+        frame.SetGroup(group_name) 
+    if map_name:
+        giface.WriteLog(_("Loading raster map <%s>...") % map_name)
+        frame.trainingMapManager.AddLayer(map_name)
+    
     frame.Show()
     
     app.MainLoop()
     
 if __name__ == '__main__':
     gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+    grass.set_raise_on_error(False)
     options, flags = grass.parser()
     main()



More information about the grass-commit mailing list