[GRASS-SVN] r30701 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 22 20:47:26 EDT 2008


Author: martinl
Date: 2008-03-22 20:47:26 -0400 (Sat, 22 Mar 2008)
New Revision: 30701

Modified:
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/gui_modules/render.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: (render/preferences) cairo driver also supported (initial)

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-03-22 21:16:14 UTC (rev 30700)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-03-23 00:47:26 UTC (rev 30701)
@@ -326,8 +326,8 @@
         self.notebook = notebook
 
     def write(self, s):
-        #        if self.notebook.GetSelection() != 1: # command output
-        #            self.notebook.SetSelection(1)
+        if self.notebook.GetSelection() != 1: # command output
+            self.notebook.SetSelection(1)
 
         s = s.replace('\n', os.linesep)
         # remove/replace escape sequences '\b' or '\r' from stream

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-03-22 21:16:14 UTC (rev 30700)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-03-23 00:47:26 UTC (rev 30701)
@@ -62,6 +62,7 @@
             #
             'display': {
                 'displayFont' : { 'value' : '' },
+                'driver': { 'type': 'default' },
                 },
             #
             # advanced
@@ -165,7 +166,8 @@
         self.internalSettings['cmd']['verbosity']['choices'] = ['grassenv',
                                                                 'verbose',
                                                                 'quiet']
-
+        self.internalSettings['display']['driver']['choices'] = ['default']
+        
     def GetMapsetPath(self):
         """Store mapset search path"""
         all, access = utils.ListOfMapsets()
@@ -493,6 +495,32 @@
                        wx.ALIGN_CENTER_VERTICAL,
                        pos=(row, 1))
 
+        #
+        # display driver
+        #
+        row = 1
+        gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+                                         label=_("Display driver:")),
+                      flag=wx.ALIGN_LEFT |
+                      wx.ALIGN_CENTER_VERTICAL,
+                      pos=(row, 0))
+        listOfDrivers = self.settings.Get(group='display', key='driver', subkey='choices', internal=True)
+        # check if cairo is available
+        if 'cairo' not in listOfDrivers:
+            for line in gcmd.Command(['d.mon', '-l']).ReadStdOutput():
+                if 'cairo' in line:
+                    listOfDrivers.append('cairo')
+                    break
+        driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
+                           choices=listOfDrivers,
+                           name="GetStringSelection")
+        driver.SetStringSelection(self.settings.Get(group='display', key='driver', subkey='type'))
+        self.winId['display:driver:type'] = driver.GetId()
+
+        gridSizer.Add(item=driver,
+                      pos=(row, 1))
+
+
         sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
         border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
 

Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-22 21:16:14 UTC (rev 30700)
+++ grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-23 00:47:26 UTC (rev 30701)
@@ -34,6 +34,7 @@
 import utils
 import gcmd
 from debug import Debug as Debug
+from preferences import globalSettings as UserSettings
 
 #
 # use g.pnmcomp for creating image composition or
@@ -115,8 +116,14 @@
         #
         # start monitor
         #
-        os.environ["GRASS_PNGFILE"] = self.mapfile
-        
+        if UserSettings.Get(group='display', key='driver', subkey='type') == 'cairo':
+            os.environ["GRASS_CAIROFILE"] = self.mapfile
+            if 'cairo' not in gcmd.Command(['d.mon', '-p']).ReadStdOutput()[0]:
+                gcmd.Command(['d.mon',
+                              'start=cairo'], stderr=None)
+        else:
+            os.environ["GRASS_PNGFILE"] = self.mapfile
+
         #
         # execute command
         #
@@ -135,7 +142,12 @@
         #
         # stop monitor
         #
-        os.unsetenv("GRASS_PNGFILE")
+        if UserSettings.Get(group='display', key='driver', subkey='type') == 'cairo':
+            gcmd.Command(['d.mon',
+                          'stop=cairo'], stderr=None)
+            os.unsetenv("GRASS_CAIROFILE")
+        else:
+            os.unsetenv("GRASS_PNGFILE")
 
         return self.mapfile
 
@@ -199,7 +211,6 @@
         # environment settings
         #
         self.env       = {}  # enviroment variables, like MAPSET, LOCATION_NAME, etc.
-        self.verbosity = 0   # --q
 
         # 
         # generated file for rendering the map
@@ -209,15 +220,8 @@
         # setting some initial env. variables
         self.InitGisEnv() # g.gisenv
         self.InitRegion()
-        os.environ["GRASS_TRANSPARENT"]     = "TRUE"
+        os.environ["GRASS_TRANSPARENT"] = "TRUE"
         os.environ["GRASS_BACKGROUNDCOLOR"] = "ffffff"
-        os.environ["GRASS_HEIGHT"]          = str(self.height)
-        os.environ["GRASS_WIDTH"]           = str(self.width)
-        os.environ["GRASS_MESSAGE_FORMAT"]  = "gui"
-        os.environ["GRASS_PNG_AUTO_WRITE"]  = "TRUE"
-        os.environ["GRASS_TRUECOLOR"]       = "TRUE"
-        os.environ["GRASS_COMPRESSION"]     = "0"
-        os.environ["GRASS_VERBOSE"]         = str(self.verbosity)
 
     def InitRegion(self):
         """
@@ -612,6 +616,14 @@
         os.environ["GRASS_REGION"] = self.SetRegion()
         os.environ["GRASS_WIDTH"]  = str(self.width)
         os.environ["GRASS_HEIGHT"] = str(self.height)
+        if UserSettings.Get(group='display', key='driver', subkey='type') == 'cairo':
+            os.environ["GRASS_AUTO_WRITE"] = "TRUE"
+            os.unsetenv("GRASS_RENDER_IMMEDIATE")
+        else:
+            os.environ["GRASS_PNG_AUTO_WRITE"] = "TRUE"
+            os.environ["GRASS_COMPRESSION"] = "0"
+            os.environ["GRASS_TRUECOLOR"] = "TRUE"
+            os.environ["GRASS_RENDER_IMMEDIATE"] = "TRUE"
 
         # render map layers
         for layer in self.layers + self.overlays:
@@ -657,15 +669,6 @@
 	    maskstr = maskstr.rstrip(',')
 	    mapoutstr = self.mapfile.replace('\\', '/')
 
-        compstring = "g.pnmcomp" + globalvar.EXT_BIN + \
-            " in=" + mapstr + \
-            " mask=" + maskstr + \
-            " opacity=" + ",".join(opacities)+ \
-            " background=255:255:255" + \
-            " width=" + str(self.width) + \
-            " height=" + str(self.height) + \
-            " output=" + mapoutstr
-
         # compose command
         complist = ["g.pnmcomp",
                    "in=%s" % ",".join(maps),
@@ -687,7 +690,6 @@
         # run g.pngcomp to get composite image
         try:
             gcmd.Command(complist)
-	    # os.system(compstring)
         except gcmd.CmdError, e:
             print >> sys.stderr, e
             return None

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-03-22 21:16:14 UTC (rev 30700)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-03-23 00:47:26 UTC (rev 30701)
@@ -128,9 +128,6 @@
         self.toolbar   = self.__createToolBar()
         self.statusbar = self.CreateStatusBar(number=1)
 
-        # set environmental variables
-        os.environ["GRASS_RENDER_IMMEDIATE"] = "TRUE"
-
         # bindings
         self.Bind(wx.EVT_CLOSE,     self.OnCloseWindow)
         self.Bind(wx.EVT_LEFT_DOWN, self.AddRaster, self.notebook)



More information about the grass-commit mailing list