[GRASS-SVN] r32516 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 4 11:55:51 EDT 2008


Author: cmbarton
Date: 2008-08-04 11:55:51 -0400 (Mon, 04 Aug 2008)
New Revision: 32516

Modified:
   grass/trunk/gui/wxpython/gui_modules/profile.py
Log:
Conditionalized use of user preferences and added default values for first time profile is run.

Modified: grass/trunk/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/profile.py	2008-08-04 15:54:49 UTC (rev 32515)
+++ grass/trunk/gui/wxpython/gui_modules/profile.py	2008-08-04 15:55:51 UTC (rev 32516)
@@ -160,23 +160,47 @@
 
         self.properties = {}
         self.properties['font'] = {}
-        self.properties['font']['prop'] = UserSettings.Get(group='profile', key='font')
+        if UserSettings.Get(group='profile', key='font'):
+            self.properties['font']['prop'] = UserSettings.Get(group='profile', key='font')
+        else:
+            self.properties['font']['prop'] = {'axisSize': 11, 'legendSize': 10, 'titleSize': 12}
         self.properties['font']['wxfont'] = wx.Font(11, wx.FONTFAMILY_SWISS,
                                                     wx.FONTSTYLE_NORMAL,
                                                     wx.FONTWEIGHT_NORMAL)
-        self.properties['marker'] = UserSettings.Get(group='profile', key='marker')
+        
+        if UserSettings.Get(group='profile', key='marker'):
+            self.properties['marker'] = UserSettings.Get(group='profile', key='marker')
+        else:
+            self.properties['marker'] = {'color': '(0, 0, 0, 255)',
+                                         'fill': 'transparent', 'type': 'triangle',
+                                         'legend': 'Segment break', 'size': 2}
 
-        self.properties['grid'] = UserSettings.Get(group='profile', key='grid')
+        if UserSettings.Get(group='profile', key='grid'):
+            self.properties['grid'] = UserSettings.Get(group='profile', key='grid')
+        else:
+            self.properties['grid'] = {'color': '(200, 200, 200, 255)', 'enabled': True}
+        self.properties['x-axis'] = {}
         
-        self.properties['x-axis'] = {}
-        self.properties['x-axis']['prop'] = UserSettings.Get(group='profile', key='x-axis')
+        if UserSettings.Get(group='profile', key='x-axis'):
+            self.properties['x-axis']['prop'] = UserSettings.Get(group='profile', key='x-axis')
+        else:
+            self.properties['x-axis']['prop'] = {'max': 0.0, 'type': 'auto',
+                                                 'log': False, 'min': 0.0}
         self.properties['x-axis']['axis'] = None
 
         self.properties['y-axis'] = {}
-        self.properties['y-axis']['prop'] = UserSettings.Get(group='profile', key='y-axis')
+        if UserSettings.Get(group='profile', key='y-axis'):
+            self.properties['y-axis']['prop'] = UserSettings.Get(group='profile', key='y-axis')
+        else:
+            self.properties['y-axis']['prop'] = {'max': 0.0, 'type': 'auto',
+                                                 'log': False, 'min': 0.0}
         self.properties['y-axis']['axis'] = None
-        self.properties['legend'] = UserSettings.Get(group='profile', key='legend')
         
+        if UserSettings.Get(group='profile', key='legend'):
+            self.properties['legend'] = UserSettings.Get(group='profile', key='legend')
+        else:
+            self.properties['legend'] = {'enabled': True}
+        
         # zooming disabled
         self.zoom = False
         # draging disabled
@@ -186,14 +210,23 @@
         self.client.SetShowScrollbars(True)
 
         # x and y axis set to normal (non-log)
-        self.client.setLogScale((False, False)) 
-        self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
-        self.client.SetYSpec(self.properties['y-axis']['prop']['type'])
+        self.client.setLogScale((False, False))
+        if self.properties['x-axis']['prop']['type']:
+            self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
+        else:
+            self.client.SetXSpec('auto')
+        
+        if self.properties['y-axis']['prop']['type']:
+            self.client.SetYSpec(self.properties['y-axis']['prop']['type'])
+        else:
+            self.client.SetYSpec('auto')
 
         #
         # Bind various events
         #
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+        
+        self.CentreOnScreen()
 
     def OnDrawTransect(self, event):
         """
@@ -217,6 +250,7 @@
         """
         Select raster map(s) to profile
         """
+        
         dlg = SetRasterDialog(parent=self)
 
         if dlg.ShowModal() == wx.ID_OK:
@@ -362,6 +396,7 @@
             self.properties['y-axis']['axis'] = None
 
         self.client.SetEnableGrid(self.properties['grid']['enabled'])
+        
         self.client.SetGridColour(wx.Color(self.properties['grid']['color'][0],
                                            self.properties['grid']['color'][1],
                                            self.properties['grid']['color'][2],
@@ -411,6 +446,7 @@
         segments, these are drawn as points. Profile transect is drawn, using
         methods in mapdisp.py
         """
+        
         if len(self.mapwin.polycoords) == 0 or self.raster[0]['name'] == '':
             dlg = wx.MessageDialog(parent=self,
                                    message=_('You must draw a transect to profile in the map display window.'),



More information about the grass-commit mailing list