Browse Source

Conditionalized use of user preferences and added default values for first time profile is run.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32516 15284696-431f-4ddb-bdfa-cd5b030d7da7
Michael Barton 16 years ago
parent
commit
c7d8229822
1 changed files with 46 additions and 10 deletions
  1. 46 10
      gui/wxpython/gui_modules/profile.py

+ 46 - 10
gui/wxpython/gui_modules/profile.py

@@ -160,22 +160,46 @@ class ProfileFrame(wx.Frame):
 
 
         self.properties = {}
         self.properties = {}
         self.properties['font'] = {}
         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,
         self.properties['font']['wxfont'] = wx.Font(11, wx.FONTFAMILY_SWISS,
                                                     wx.FONTSTYLE_NORMAL,
                                                     wx.FONTSTYLE_NORMAL,
                                                     wx.FONTWEIGHT_NORMAL)
                                                     wx.FONTWEIGHT_NORMAL)
-        self.properties['marker'] = UserSettings.Get(group='profile', key='marker')
-
-        self.properties['grid'] = UserSettings.Get(group='profile', key='grid')
         
         
+        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}
+
+        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['x-axis']['axis'] = None
 
 
         self.properties['y-axis'] = {}
         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['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
         # zooming disabled
         self.zoom = False
         self.zoom = False
@@ -186,14 +210,23 @@ class ProfileFrame(wx.Frame):
         self.client.SetShowScrollbars(True)
         self.client.SetShowScrollbars(True)
 
 
         # x and y axis set to normal (non-log)
         # 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
         # Bind various events
         #
         #
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+        
+        self.CentreOnScreen()
 
 
     def OnDrawTransect(self, event):
     def OnDrawTransect(self, event):
         """
         """
@@ -217,6 +250,7 @@ class ProfileFrame(wx.Frame):
         """
         """
         Select raster map(s) to profile
         Select raster map(s) to profile
         """
         """
+        
         dlg = SetRasterDialog(parent=self)
         dlg = SetRasterDialog(parent=self)
 
 
         if dlg.ShowModal() == wx.ID_OK:
         if dlg.ShowModal() == wx.ID_OK:
@@ -362,6 +396,7 @@ class ProfileFrame(wx.Frame):
             self.properties['y-axis']['axis'] = None
             self.properties['y-axis']['axis'] = None
 
 
         self.client.SetEnableGrid(self.properties['grid']['enabled'])
         self.client.SetEnableGrid(self.properties['grid']['enabled'])
+        
         self.client.SetGridColour(wx.Color(self.properties['grid']['color'][0],
         self.client.SetGridColour(wx.Color(self.properties['grid']['color'][0],
                                            self.properties['grid']['color'][1],
                                            self.properties['grid']['color'][1],
                                            self.properties['grid']['color'][2],
                                            self.properties['grid']['color'][2],
@@ -411,6 +446,7 @@ class ProfileFrame(wx.Frame):
         segments, these are drawn as points. Profile transect is drawn, using
         segments, these are drawn as points. Profile transect is drawn, using
         methods in mapdisp.py
         methods in mapdisp.py
         """
         """
+        
         if len(self.mapwin.polycoords) == 0 or self.raster[0]['name'] == '':
         if len(self.mapwin.polycoords) == 0 or self.raster[0]['name'] == '':
             dlg = wx.MessageDialog(parent=self,
             dlg = wx.MessageDialog(parent=self,
                                    message=_('You must draw a transect to profile in the map display window.'),
                                    message=_('You must draw a transect to profile in the map display window.'),