[GRASS-SVN] r33185 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 1 06:32:30 EDT 2008


Author: martinl
Date: 2008-09-01 06:32:30 -0400 (Mon, 01 Sep 2008)
New Revision: 33185

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: render command layer on enter
multiple commands separated by ';' can be entered
	trac #268


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-09-01 10:05:26 UTC (rev 33184)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-09-01 10:32:30 UTC (rev 33185)
@@ -140,8 +140,20 @@
         # execute command
         #
         try:
-            runcmd = gcmd.Command(cmd=self.cmdlist + ['--q'],
-                                  stderr=None)
+            if self.type == 'command':
+                read = False
+                for cmd in self.cmdlist:
+                    runcmd = gcmd.Command(cmd=cmd + ['--q'],
+                                          stderr=None)
+                    if runcmd.returncode != 0:
+                        break
+                    if not read:
+                        os.environ["GRASS_PNG_READ"] = "TRUE"
+                
+                os.environ["GRASS_PNG_READ"] = "FALSE"
+            else:
+                runcmd = gcmd.Command(cmd=self.cmdlist + ['--q'],
+                                      stderr=None)
             
             if runcmd.returncode != 0:
                 #clean up after probley
@@ -189,7 +201,13 @@
         @return command list/string
         """
         if string:
-            return ' '.join(self.cmdlist)
+            if self.type == 'command':
+                cmdStr = ''
+                for cmd in self.cmdlist:
+                    cmdStr += ' '.join(cmd) + ';'
+                return cmdStr
+            else:
+                return ' '.join(self.cmdlist)
         else:
             return self.cmdlist
 
@@ -266,7 +284,7 @@
         """Set new command for layer"""
         self.cmdlist = cmd
         Debug.msg(3, "Layer.SetCmd(): cmd='%s'" % self.GetCmd(string=True))
-
+        
         # for re-rendering
         self.force_render = True
         
@@ -854,6 +872,7 @@
             os.unsetenv("GRASS_RENDER_IMMEDIATE")
         else:
             os.environ["GRASS_PNG_AUTO_WRITE"] = "TRUE"
+            os.environ["GRASS_PNG_READ"] = "FALSE"
             os.environ["GRASS_COMPRESSION"] = "0"
             os.environ["GRASS_TRUECOLOR"] = "TRUE"
             os.environ["GRASS_RENDER_IMMEDIATE"] = "TRUE"
@@ -1014,10 +1033,10 @@
 
         if kargs.has_key('type'):
             layer.SetType(kargs['type']) # check type
-
+        
         if kargs.has_key('command'):
             layer.SetCmd(kargs['command'])
-            
+        
         if kargs.has_key('name'):
             layer.SetName(kargs['name'])
 

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py	2008-09-01 10:05:26 UTC (rev 33184)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py	2008-09-01 10:32:30 UTC (rev 33185)
@@ -540,10 +540,11 @@
         if ltype == 'command':
             # generic command item
             ctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
-                               pos=wx.DefaultPosition, size=(250,25),
-                               style=wx.TE_MULTILINE|wx.TE_WORDWRAP)
+                               pos=wx.DefaultPosition, size=(self.GetSize()[0]-100,25),
+                               # style=wx.TE_MULTILINE|wx.TE_WORDWRAP)
+                               style=wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)
             ctrl.Bind(wx.EVT_TEXT_ENTER, self.OnCmdChanged)
-            ctrl.Bind(wx.EVT_TEXT,       self.OnCmdChanged)
+            # ctrl.Bind(wx.EVT_TEXT,       self.OnCmdChanged)
         elif ltype == 'group':
             # group item
             ctrl = None
@@ -900,9 +901,14 @@
                     # ignore when map layer is edited
                     self.Map.ChangeLayerActive(mapLayer, checked)
 
+        #
         # update progress bar range (mapwindow statusbar)
+        #
         self.mapdisplay.onRenderGauge.SetRange(len(self.Map.GetListOfLayers(l_active=True)))
 
+        #
+        # nviz
+        #
         if self.mapdisplay.toolbars['nviz'] and \
                 self.GetPyData(item) is not None:
             # nviz - load/unload data layer
@@ -967,6 +973,10 @@
         """Selection changed"""
         oldlayer = event.GetOldItem()
         layer = event.GetItem()
+        if layer == oldlayer:
+            event.Veto()
+            return
+        
         self.layer_selected = layer
         
         try:
@@ -975,13 +985,17 @@
         except:
             pass
 
+        #
         # update statusbar -> show command string
+        #
         if self.GetPyData(layer) and self.GetPyData(layer)[0]['maplayer']:
             cmd = self.GetPyData(layer)[0]['maplayer'].GetCmd(string=True)
             if len(cmd) > 0:
                 self.gismgr.SetStatusText(cmd)
         
+        #
         # update nviz tools
+        #
         if self.mapdisplay.toolbars['nviz'] and \
                 self.GetPyData(self.layer_selected) is not None:
 
@@ -1253,13 +1267,16 @@
 
     def ChangeLayer(self, item):
         """Change layer"""
-
         type = self.GetPyData(item)[0]['type']
-
+        layerName = None
+        
         if type == 'command':
             win = self.FindWindowById(self.GetPyData(item)[0]['ctrl'])
             if win.GetValue() != None:
-                cmdlist = win.GetValue().split(' ')
+                cmd = win.GetValue().split(';')
+                cmdlist = []
+                for c in cmd:
+                    cmdlist.append(c.split(' '))
                 opac = 1.0
                 chk = self.IsItemChecked(item)
                 hidden = not self.IsVisible(item)
@@ -1269,29 +1286,28 @@
                 opac = self.GetPyData(item)[0]['maplayer'].GetOpacity(float=True)
                 chk = self.IsItemChecked(item)
                 hidden = not self.IsVisible(item)
-        # determine layer name
-        layerName = utils.GetLayerNameFromCmd(cmdlist, fullyQualified=True)
-        if not layerName:
-            layerName = self.GetItemText(item)
+                # determine layer name
+                layerName = utils.GetLayerNameFromCmd(cmdlist, fullyQualified=True)
+                if not layerName:
+                    layerName = self.GetItemText(item)
+        
         maplayer = self.Map.ChangeLayer(layer=self.GetPyData(item)[0]['maplayer'], type=type,
                                         command=cmdlist, name=layerName,
                                         l_active=chk, l_hidden=hidden, l_opacity=opac, l_render=False)
-
+        
         self.GetPyData(item)[0]['maplayer'] = maplayer
-
+        
         # if digitization tool enabled -> update list of available vector map layers
         if self.mapdisplay.toolbars['vdigit']:
             self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers(updateTool=True)
-
+        
         # redraw map if auto-rendering is enabled
         self.rerender = True
         self.reorder = True
         #if self.mapdisplay.autoRender.GetValue():
         #    print "*** Change OnRender *****"
         #    self.mapdisplay.OnRender(None)
-
-        # item.SetHeight(TREE_ITEM_HEIGHT)
-
+        
     def OnCloseWindow(self, event):
         pass
         # self.Map.Clean()



More information about the grass-commit mailing list