[GRASS-SVN] r41226 - in grass/trunk/gui/wxpython: gui_modules icons

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 28 12:32:22 EST 2010


Author: cmbarton
Date: 2010-02-28 12:32:20 -0500 (Sun, 28 Feb 2010)
New Revision: 41226

Modified:
   grass/trunk/gui/wxpython/gui_modules/profile.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
   grass/trunk/gui/wxpython/icons/grass2_icons.py
   grass/trunk/gui/wxpython/icons/grass_icons.py
   grass/trunk/gui/wxpython/icons/icon.py
   grass/trunk/gui/wxpython/icons/silk_icons.py
Log:
Add option to save profile data to csv file for processing in external app.

Modified: grass/trunk/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/profile.py	2010-02-28 15:05:08 UTC (rev 41225)
+++ grass/trunk/gui/wxpython/gui_modules/profile.py	2010-02-28 17:32:20 UTC (rev 41226)
@@ -602,6 +602,41 @@
         """
         self.client.SaveFile()
 
+    def SaveProfileToFile(self, event):
+        """
+        Save r.profile data to a csv file
+        """    
+        
+        wildcard = "Comma separated value (*.csv)|*.csv" 
+        
+        dlg = wx.FileDialog(
+            self, message="Path and prefix (for raster name) to save profile values...", defaultDir=os.getcwd(), 
+            defaultFile="",  wildcard=wildcard, style=wx.SAVE
+            )
+        if dlg.ShowModal() == wx.ID_OK:
+            path = dlg.GetPath()
+            
+            for r in self.raster.itervalues():
+                if r['name'] == '':
+                    continue
+
+                print 'path = '+str(path)
+                pfile = path+'_'+str(r['name'])+'.csv'
+                print 'pfile1 = '+str(pfile)
+                try:
+                    file = open(pfile, "w")
+                except IOError:
+                    wx.MessageBox(parent=self,
+                                  message=_("Unable to open file <%s> for writing.") % pfile,
+                                  caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+                    return False
+                for datapair in r['datalist']:
+                    file.write('%d,%d\n' % (float(datapair[0]),float(datapair[1])))
+                                        
+                file.close()
+
+        dlg.Destroy()
+
     def DrawPointLabel(self, dc, mDataDict):
         """!This is the fuction that defines how the pointLabels are plotted
             dc - DC that will be passed
@@ -1030,7 +1065,7 @@
         btnCancel = wx.Button(self, wx.ID_CANCEL)
         btnSave.SetDefault()
 
-        # bindigs
+        # bindings
         btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
         btnApply.SetToolTipString(_("Apply changes for the current session"))
         btnSave.Bind(wx.EVT_BUTTON, self.OnSave)

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2010-02-28 15:05:08 UTC (rev 41225)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2010-02-28 17:32:20 UTC (rev 41226)
@@ -1277,6 +1277,7 @@
         self.unzoom = wx.NewId()
         self.erase = wx.NewId()
         self.save = wx.NewId()
+        self.datasave = wx.NewId()
         self.printer = wx.NewId()
         self.quit = wx.NewId()
                 
@@ -1307,9 +1308,12 @@
              wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
              self.parent.OnErase),
             ("", "", "", "", "", "", ""),
-            (self.save, 'save', Icons["savefile"].GetBitmap(),
+            (self.save, 'save image', Icons["savefile"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
              self.parent.SaveToFile),
+            (self.datasave, 'save data', Icons["datasave"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["datasave"].GetLabel(), Icons["datasave"].GetDesc(),
+             self.parent.SaveProfileToFile),
             (self.printer, 'print', Icons["printmap"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
              self.parent.PrintMenu),

Modified: grass/trunk/gui/wxpython/icons/grass2_icons.py
===================================================================
--- grass/trunk/gui/wxpython/icons/grass2_icons.py	2010-02-28 15:05:08 UTC (rev 41225)
+++ grass/trunk/gui/wxpython/icons/grass2_icons.py	2010-02-28 17:32:20 UTC (rev 41226)
@@ -89,6 +89,7 @@
     "transect"     : 'layer-raster-profile.png',
     "profiledraw"  : 'show.png',
     "profileopt"   : 'settings.png',
+    "datasave"     : 'save.png',
     # georectify
     "grGcpSet"     : 'gcp-create.png',
     'grGcpClear'   : 'gcp-remove.png',

Modified: grass/trunk/gui/wxpython/icons/grass_icons.py
===================================================================
--- grass/trunk/gui/wxpython/icons/grass_icons.py	2010-02-28 15:05:08 UTC (rev 41225)
+++ grass/trunk/gui/wxpython/icons/grass_icons.py	2010-02-28 17:32:20 UTC (rev 41226)
@@ -89,6 +89,7 @@
     # profile 
     "profile"    : 'gui-profile.gif',
     "transect"   : 'gui-profiledefine.gif',
+    "datasave"   : 'file-save.gif',
     # "profiledraw": 'gui-profiledraw.gif',
     "profiledraw" : 'gui-display.gif',
     "profileopt" : 'gui-profileopt.gif',

Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py	2010-02-28 15:05:08 UTC (rev 41225)
+++ grass/trunk/gui/wxpython/icons/icon.py	2010-02-28 17:32:20 UTC (rev 41226)
@@ -296,6 +296,8 @@
                              label=_("Draw/re-draw profile")),
     "profileopt" : MetaIcon (img=Icons["profileopt"],
                              label=_("Profile options")),
+    "datasave"   : MetaIcon (img=Icons["datasave"],
+                             label=_("Save profile data to csv file")),
     "histogram"  : MetaIcon (img=Icons["histogram"],
                              label=_("Create histogram of image or raster file")),
     "font"       : MetaIcon (img=Icons["font"],

Modified: grass/trunk/gui/wxpython/icons/silk_icons.py
===================================================================
--- grass/trunk/gui/wxpython/icons/silk_icons.py	2010-02-28 15:05:08 UTC (rev 41225)
+++ grass/trunk/gui/wxpython/icons/silk_icons.py	2010-02-28 17:32:20 UTC (rev 41226)
@@ -91,6 +91,7 @@
     "transect"   : 'image_edit.png',
     "profiledraw"  : 'arrow_refresh.png',
     "profileopt"   : 'color_swatch.png',
+    "datasave"     : 'page_save.png',
     # georectify
     "grGcpSet"     : 'bullet_add.png',
     'grGcpClear'   : 'cross.png',


Property changes on: grass/trunk/gui/wxpython/icons/silk_icons.py
___________________________________________________________________
Deleted: svn:mergeinfo
   - 



More information about the grass-commit mailing list