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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 6 08:19:42 EDT 2009


Author: martinl
Date: 2009-07-06 08:19:42 -0400 (Mon, 06 Jul 2009)
New Revision: 38284

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: format coordinates in the mapdisplay statusbar (deg/dms,
precision)
	  (merge from trunk, r38283)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2009-07-06 12:08:13 UTC (rev 38283)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2009-07-06 12:19:42 UTC (rev 38284)
@@ -545,6 +545,10 @@
         """
         # update statusbar if required
         if self.statusbarWin['toggle'].GetSelection() == 0: # Coordinates
+            precision = int(UserSettings.Get(group = 'projection', key = 'format',
+                                             subkey = 'precision'))
+            format = UserSettings.Get(group = 'projection', key = 'format',
+                                      subkey = 'll')
             e, n = self.MapWindow.Pixel2Cell(event.GetPositionTuple())
             if self.toolbars['vdigit'] and \
                     self.toolbars['vdigit'].GetAction() == 'addLine' and \
@@ -558,32 +562,40 @@
                     distance_tot += self.MapWindow.Distance(self.MapWindow.polycoords[idx-1],
                                                             self.MapWindow.polycoords[idx],
                                                             screen=False )[0]
-                self.statusbar.SetStatusText("%.2f, %.2f (seg: %.2f; tot: %.2f)" % \
-                                                 (e, n, distance_seg, distance_tot), 0)
+                self.statusbar.SetStatusText("%.*f, %.*f (seg: %.*f; tot: %.*f)" % \
+                                                 (precision, e, precision, n,
+                                                  precision, distance_seg,
+                                                  precision, distance_tot), 0)
             else:
                 if self.statusbarWin['projection'].IsChecked():
-                    if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+                    if not UserSettings.Get(group='projection', key='statusbar', subkey='proj4'):
                         self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
                     else:
                         proj, coord  = utils.ReprojectCoordinates(coord = (e, n),
-                                                                  projOut = UserSettings.Get(group='display',
-                                                                                             key='projection',
+                                                                  projOut = UserSettings.Get(group='projection',
+                                                                                             key='statusbar',
                                                                                              subkey='proj4'),
                                                                   flags = 'd')
                     
                         if coord:
                             e, n = coord
-                            if proj in ('ll', 'latlong', 'longlat'):
-                                self.statusbar.SetStatusText("%s" % utils.Deg2DMS(e, n), 0)
+                            if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
+                                self.statusbar.SetStatusText("%s" % \
+                                                                 utils.Deg2DMS(e, n, precision = precision),
+                                                             0)
                             else:
-                                self.statusbar.SetStatusText("%.2f; %.2f" % (e, n), 0)
+                                self.statusbar.SetStatusText("%.*f; %.*f" % \
+                                                                 (precision, e, precision, n), 0)
                         else:
                             self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
                 else:
-                    if self.Map.projinfo['proj'] == 'll':
-                        self.statusbar.SetStatusText("%s" % utils.Deg2DMS(e, n), 0)
+                    if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
+                        self.statusbar.SetStatusText("%s" % \
+                                                         utils.Deg2DMS(e, n, precision = precision),
+                                                     0)
                     else:
-                        self.statusbar.SetStatusText("%.2f; %.2f" % (e, n), 0)
+                        self.statusbar.SetStatusText("%.*f; %.*f" % \
+                                                         (precision, e, precision, n), 0)
                 
         event.Skip()
 
@@ -805,12 +817,12 @@
         """
         try:
             if self.statusbarWin['projection'].IsChecked():
-                if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+                if not UserSettings.Get(group='projection', key='statusbar', subkey='proj4'):
                     self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
                 else:
                     # reproject values
-                    projIn = UserSettings.Get(group='display',
-                                              key='projection',
+                    projIn = UserSettings.Get(group='projection',
+                                              key='statusbar',
                                               subkey='proj4')
                     projOut = gcmd.RunCommand('g.proj',
                                               flags = 'jf',
@@ -837,7 +849,7 @@
                     
             region = self.Map.GetCurrentRegion()
             if self.statusbarWin['projection'].IsChecked():
-                if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+                if not UserSettings.Get(group='projection', key='statusbar', subkey='proj4'):
                     self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
                 else:
                     region['center_easting'], region['center_northing'] = e, n
@@ -848,12 +860,18 @@
                     region['center_easting'], region['center_northing'] = e, n
         except ValueError:
             region = self.Map.GetCurrentRegion()
-            if self.Map.projinfo['proj'] == 'll':
+            precision = int(UserSettings.Get(group = 'projection', key = 'format',
+                                             subkey = 'precision'))
+            format = UserSettings.Get(group = 'projection', key = 'format',
+                                      subkey = 'll')
+            if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
                     self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(region['center_easting'], 
-                                                                            region['center_northing']))
+                                                                            region['center_northing'],
+                                                                            precision = precision))
             else:
-                self.statusbarWin['goto'].SetValue("%.2f; %.2f" % (region['center_easting'],
-                                                                   region['center_northing']))
+                self.statusbarWin['goto'].SetValue("%.*f; %.*f" % \
+                                                       (precision, region['center_easting'],
+                                                        precision, region['center_northing']))
             return
         
         
@@ -896,12 +914,17 @@
             else:
                 region = self.Map.GetRegion() # computation region
 
+            precision = int(UserSettings.Get(group = 'projection', key = 'format',
+                                             subkey = 'precision'))
+            format = UserSettings.Get(group = 'projection', key = 'format',
+                                      subkey = 'll')
+            
             if self.statusbarWin['projection'].IsChecked():
-                if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+                if not UserSettings.Get(group='projection', key='statusbar', subkey='proj4'):
                     self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
                 else:
-                    projOut = UserSettings.Get(group='display',
-                                               key='projection',
+                    projOut = UserSettings.Get(group='projection',
+                                               key='statusbar',
                                                subkey='proj4')
                     proj, coord1 = utils.ReprojectCoordinates(coord = (region["w"], region["s"]),
                                                               projOut = projOut, flags = 'd')
@@ -913,50 +936,57 @@
                         proj, coord4 = utils.ReprojectCoordinates(coord = (region["ewres"], region["nsres"]),
                                                                   projOut = projOut, flags = 'd')
                     if coord1 and coord2:
-                        if proj in ('ll', 'latlong', 'longlat'):
-                            w, s = utils.Deg2DMS(coord1[0], coord1[1], string = False)
-                            e, n = utils.Deg2DMS(coord2[0], coord2[1], string = False)
+                        if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
+                            w, s = utils.Deg2DMS(coord1[0], coord1[1], string = False,
+                                                 precision = precision)
+                            e, n = utils.Deg2DMS(coord2[0], coord2[1], string = False,
+                                                 precision = precision)
                             if sel == 1:
                                 self.statusbar.SetStatusText("%s - %s, %s - %s" %
                                                              (w, e, s, n), 0)
                             else:
                                 ewres, nsres = utils.Deg2DMS(abs(coord3[0]) - abs(coord4[0]),
                                                              abs(coord3[1]) - abs(coord4[1]),
-                                                             string = False, hemisphere = False)
+                                                             string = False, hemisphere = False,
+                                                             precision = precision)
                                 self.statusbar.SetStatusText("%s - %s, %s - %s (%s, %s)" %
                                                              (w, e, s, n, ewres, nsres), 0)
                         else:
                             w, s = coord1
                             e, n = coord2
                             if sel == 1:
-                                self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f" %
-                                                         (w, e, s, n), 0)
+                                self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f" %
+                                                         (precision, w, precision, e,
+                                                          precision, s, precision, n), 0)
                             else:
                                 ewres, nsres = coord3
-                                self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f (%.2f, %.2f)" %
-                                                             (w, e, s, n, ewres, nsres), 0)
+                                self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" %
+                                                             (precision, w, precision, e,
+                                                              precision, s, precision, n,
+                                                              precision, ewres, precision, nsres), 0)
                     else:
                         self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
             else:
-                if self.Map.projinfo['proj'] == 'll':
+                if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
                     w, s = utils.Deg2DMS(region["w"], region["s"],
-                                         string = False)
+                                         string = False, precision = precision)
                     e, n = utils.Deg2DMS(region["e"], region["n"],
-                                         string = False)
+                                         string = False, precision = precision)
                     if sel == 1:
                         self.statusbar.SetStatusText("%s - %s, %s - %s" %
                                                      (w, e, s, n), 0)
                     else:
                         ewres, nsres = utils.Deg2DMS(region['ewres'], region['nsres'],
-                                                     string = False)
+                                                     string = False, precision = precision)
                         self.statusbar.SetStatusText("%s - %s, %s - %s (%s, %s)" %
                                                      (w, e, s, n, ewres, nsres), 0)
                 else:
                     w, s = region["w"], region["s"]
                     e, n = region["e"], region["n"]
                     if sel == 1:
-                        self.statusbar.SetStatusText("%.2f - %.2f, %.2f - %.2f" %
-                                                     (w, e, s, n), 0)
+                        self.statusbar.SetStatusText("%.*f - %.*f, %.*f - %.*f" %
+                                                     (precision, w, precision, e,
+                                                      precision, s, precision, n), 0)
                     else:
                         ewres, nsres = region['ewres'], region['nsres']
                         self.statusbar.SetStatusText("%s - %s, %s - %s (%s, %s)" %
@@ -1035,32 +1065,39 @@
         elif self.statusbarWin['toggle'].GetSelection() == 7: # go to
             self.statusbar.SetStatusText("")
             region = self.Map.GetCurrentRegion()
+            precision = int(UserSettings.Get(group = 'projection', key = 'format',
+                                             subkey = 'precision'))
+            format = UserSettings.Get(group = 'projection', key = 'format',
+                                      subkey = 'll')
+            
             if self.statusbarWin['projection'].IsChecked():
-                if not UserSettings.Get(group='display', key='projection', subkey='proj4'):
+                if not UserSettings.Get(group='projection', key='statusbar', subkey='proj4'):
                     self.statusbar.SetStatusText(_("Projection not defined (check the settings)"), 0)
                 else:
                     proj, coord  = utils.ReprojectCoordinates(coord = (region['center_easting'],
                                                                        region['center_northing']),
-                                                              projOut = UserSettings.Get(group='display',
-                                                                                         key='projection',
+                                                              projOut = UserSettings.Get(group='projection',
+                                                                                         key='statusbar',
                                                                                          subkey='proj4'),
                                                               flags = 'd')
                     if coord:
-                        if proj in ('ll', 'latlong', 'longlat'):
+                        if proj in ('ll', 'latlong', 'longlat') and format == 'DMS':
                             self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(coord[0],
-                                                                                coord[1]))
+                                                                                    coord[1],
+                                                                                    precision = precision))
                         else:
-                            self.statusbarWin['goto'].SetValue("%.2f; %.2f" % (coord[0],
-                                                                           coord[1]))
+                            self.statusbarWin['goto'].SetValue("%.*f; %.*f" % (precision, coord[0],
+                                                                               precision, coord[1]))
                     else:
                         self.statusbar.SetStatusText(_("Error in projection (check the settings)"), 0)
             else:
-                if self.Map.projinfo['proj'] == 'll':
+                if self.Map.projinfo['proj'] == 'll' and format == 'DMS':
                     self.statusbarWin['goto'].SetValue("%s" % utils.Deg2DMS(region['center_easting'], 
-                                                                            region['center_northing']))
+                                                                            region['center_northing'],
+                                                                            precision = precision))
                 else:
-                    self.statusbarWin['goto'].SetValue("%.2f; %.2f" % (region['center_easting'],
-                                                                       region['center_northing']))
+                    self.statusbarWin['goto'].SetValue("%.*f; %.*f" % (precision, region['center_easting'],
+                                                                       precision, region['center_northing']))
             self.statusbarWin['goto'].Show()
 
             # disable long help
@@ -1068,7 +1105,7 @@
         
         elif self.statusbarWin['toggle'].GetSelection() == 8: # projection
             self.statusbar.SetStatusText("")
-            epsg = UserSettings.Get(group='display', key='projection', subkey='epsg')
+            epsg = UserSettings.Get(group='projection', key='statusbar', subkey='epsg')
             if epsg:
                 label = '%s (EPSG: %s)' % (_("Use defined projection"), epsg)
                 self.statusbarWin['projection'].SetLabel(label)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2009-07-06 12:08:13 UTC (rev 38283)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2009-07-06 12:19:42 UTC (rev 38284)
@@ -113,10 +113,19 @@
                 'bgcolor': {
                     'color' : (255, 255, 255, 255),
                     },
-                'projection' : {
+                },
+            #
+            # projection
+            #
+            'projection' : {
+                'statusbar' : {
                     'proj4'   : '',
                     'epsg'    : '',
                     },
+                'format' : {
+                    'll'  : 'DMS',
+                    'precision' : 6,
+                    },
                 },
             #
             # advanced
@@ -843,6 +852,7 @@
         self.__CreateDisplayPage(notebook)
         self.__CreateCmdPage(notebook)
         self.__CreateAttributeManagerPage(notebook)
+        self.__CreateProjectionPage(notebook)
         self.__CreateWorkspacePage(notebook)
         self.__CreateAdvancedPage(notebook)
 
@@ -1131,89 +1141,11 @@
 
         sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
         border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
-
-        #
-        # projections statusbar settings
-        #
-        box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Projection statusbar settings"))
-        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
-
-        gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
-        gridSizer.AddGrowableCol(1)
-
-        row = 0
-        # useProj = wx.CheckBox(parent=panel, id=wx.ID_ANY,
-        # label=_("Use defined projection"),
-        #                       name="IsChecked")
-        # useProj.SetValue(self.settings.Get(group='display', key='projection', subkey='enabled'))
-        # self.winId['display:projection:enabled'] = useProj.GetId()
-        #
-        # gridSizer.Add(item=useProj,
-        #              pos=(row, 0), span=(1, 3))
-
-        # epsg
-        #row += 1
-        label = wx.StaticText(parent=panel, id=wx.ID_ANY,
-                              label=_("EPSG code:"))
-        epsgCode = wx.ComboBox(parent=panel, id=wx.ID_ANY,
-                               name="GetValue",
-                               size = (150, -1))
-        self.epsgCodeDict = dict()
-        epsgCode.SetValue(str(self.settings.Get(group='display', key='projection', subkey='epsg')))
-        self.winId['display:projection:epsg'] = epsgCode.GetId()
         
-        gridSizer.Add(item=label,
-                      pos=(row, 0),
-                      flag = wx.ALIGN_CENTER_VERTICAL)
-        gridSizer.Add(item=epsgCode,
-                      pos=(row, 1), span=(1, 2))
-        
-        # proj
-        row += 1
-        label = wx.StaticText(parent=panel, id=wx.ID_ANY,
-                              label=_("Proj.4 string (required):"))
-        projString = wx.TextCtrl(parent=panel, id=wx.ID_ANY,
-                                 value=self.settings.Get(group='display', key='projection', subkey='proj4'),
-                                 name="GetValue", size=(400, -1))
-        self.winId['display:projection:proj4'] = projString.GetId()
-
-        gridSizer.Add(item=label,
-                      pos=(row, 0),
-                      flag = wx.ALIGN_CENTER_VERTICAL)
-        gridSizer.Add(item=projString,
-                      pos=(row, 1), span=(1, 2),
-                      flag = wx.ALIGN_CENTER_VERTICAL)
-        
-        # epsg file
-        row += 1
-        label = wx.StaticText(parent=panel, id=wx.ID_ANY,
-                              label=_("EPSG file:"))
-        projFile = wx.TextCtrl(parent=panel, id=wx.ID_ANY,
-                               value=utils.PathJoin(os.environ["GRASS_PROJSHARE"], 'epsg'),
-                               name="GetValue", size=(400, -1))
-        epsgLoad = wx.Button(parent=panel, id=wx.ID_ANY,
-                             label=_("&Load EPSG codes"))
-        self.winId['display:projection:projFile'] = projFile.GetId()
-        
-        gridSizer.Add(item=label,
-                      pos=(row, 0),
-                      flag = wx.ALIGN_CENTER_VERTICAL)
-        gridSizer.Add(item=projFile,
-                      pos=(row, 1),
-                      flag = wx.ALIGN_CENTER_VERTICAL)
-        gridSizer.Add(item=epsgLoad,
-                      pos=(row, 2))
-        
-        sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
-        border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
-
         panel.SetSizer(border)
         
         # bindings
         fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
-        epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
-        epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
-        epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
         
         return panel
 
@@ -1463,6 +1395,141 @@
 
         return panel
 
+    def __CreateProjectionPage(self, notebook):
+        """!Create notebook page for workspace settings"""
+        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
+        notebook.AddPage(page=panel, text=_("Projection"))
+        
+        border = wx.BoxSizer(wx.VERTICAL)
+        
+        #
+        # projections statusbar settings
+        #
+        box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Projection statusbar settings"))
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
+        gridSizer.AddGrowableCol(1)
+
+        # epsg
+        row = 0
+        label = wx.StaticText(parent=panel, id=wx.ID_ANY,
+                              label=_("EPSG code:"))
+        epsgCode = wx.ComboBox(parent=panel, id=wx.ID_ANY,
+                               name="GetValue",
+                               size = (150, -1))
+        self.epsgCodeDict = dict()
+        epsgCode.SetValue(str(self.settings.Get(group='projection', key='statusbar', subkey='epsg')))
+        self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
+        
+        gridSizer.Add(item=label,
+                      pos=(row, 0),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+        gridSizer.Add(item=epsgCode,
+                      pos=(row, 1), span=(1, 2))
+        
+        # proj
+        row += 1
+        label = wx.StaticText(parent=panel, id=wx.ID_ANY,
+                              label=_("Proj.4 string (required):"))
+        projString = wx.TextCtrl(parent=panel, id=wx.ID_ANY,
+                                 value=self.settings.Get(group='projection', key='statusbar', subkey='proj4'),
+                                 name="GetValue", size=(400, -1))
+        self.winId['projection:statusbar:proj4'] = projString.GetId()
+
+        gridSizer.Add(item=label,
+                      pos=(row, 0),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+        gridSizer.Add(item=projString,
+                      pos=(row, 1), span=(1, 2),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+        
+        # epsg file
+        row += 1
+        label = wx.StaticText(parent=panel, id=wx.ID_ANY,
+                              label=_("EPSG file:"))
+        projFile = wx.TextCtrl(parent=panel, id=wx.ID_ANY,
+                               value=utils.PathJoin(os.environ["GRASS_PROJSHARE"], 'epsg'),
+                               name="GetValue", size=(400, -1))
+        self.winId['projection:statusbar:projFile'] = projFile.GetId()
+        gridSizer.Add(item=label,
+                      pos=(row, 0),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+        gridSizer.Add(item=projFile,
+                      pos=(row, 1),
+                      flag = wx.ALIGN_CENTER_VERTICAL)
+        
+        # note + button
+        row += 1
+        note = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                             label = _("Load EPSG codes (be patient), enter EPSG code or "
+                                       "insert Proj.4 string directly."))
+        gridSizer.Add(item=note,
+                      span = (1, 2),
+                      pos=(row, 0))
+
+        row += 1
+        epsgLoad = wx.Button(parent=panel, id=wx.ID_ANY,
+                             label=_("&Load EPSG codes"))
+        gridSizer.Add(item=epsgLoad,
+                      flag = wx.ALIGN_RIGHT,
+                      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)
+
+        #
+        # format
+        #
+        box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Coordinates format"))
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+        
+        gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
+        gridSizer.AddGrowableCol(2)
+
+        row = 0
+        # ll format
+        ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
+                         label = " %s " % _("LL projections"),
+                         choices = ["DMS", "DEG"],
+                         name = "GetStringSelection")
+        self.winId['projection:format:ll'] = ll.GetId()
+        if self.settings.Get(group = 'projection', key = 'format', subkey = 'll') == 'DMS':
+            ll.SetSelection(0)
+        else:
+            ll.SetSelection(1)
+        
+        # precision
+        precision =  wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
+                                 min = 0, max = 12,
+                                 name = "GetValue")
+        precision.SetValue(int(self.settings.Get(group = 'projection', key = 'format', subkey = 'precision')))
+        self.winId['projection:format:precision'] = precision.GetId()
+                
+        gridSizer.Add(item=ll,
+                      pos=(row, 0))
+        gridSizer.Add(item=wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                         label = _("Precision:")),
+                      flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
+                      border = 20,
+                      pos=(row, 1))
+        gridSizer.Add(item=precision,
+                      flag = wx.ALIGN_CENTER_VERTICAL,
+                      pos=(row, 2))
+        
+        
+        sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
+        border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
+        
+        panel.SetSizer(border)
+
+        # bindings
+        epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
+        epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
+        epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
+        
+        return panel
+
     def __CreateWorkspacePage(self, notebook):
         """!Create notebook page for workspace settings"""
         panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
@@ -1578,11 +1645,11 @@
 
     def OnLoadEpsgCodes(self, event):
         """!Load EPSG codes from the file"""
-        win = self.FindWindowById(self.winId['display:projection:projFile'])
+        win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
         path = win.GetValue()
 
         self.epsgCodeDict = utils.ReadEpsgCodes(path)
-        list = self.FindWindowById(self.winId['display:projection:epsg'])
+        list = self.FindWindowById(self.winId['projection:statusbar:epsg'])
         if type(self.epsgCodeDict) == type(''):
             wx.MessageBox(parent=self,
                           message=_("Unable to read EPSG codes: %s") % self.epsgCodeDict,
@@ -1590,14 +1657,14 @@
             self.epsgCodeDict = dict()
             list.SetItems([])
             list.SetValue('')
-            self.FindWindowById(self.winId['display:projection:proj4']).SetValue('')
+            self.FindWindowById(self.winId['projection:statusbar:proj4']).SetValue('')
             return
         
         choices = map(str, self.epsgCodeDict.keys())
 
         list.SetItems(choices)
         code = int(list.GetValue())
-        win = self.FindWindowById(self.winId['display:projection:proj4'])
+        win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
         if self.epsgCodeDict.has_key(code):
             win.SetValue(self.epsgCodeDict[code][1])
         else:
@@ -1608,7 +1675,7 @@
     def OnSetEpsgCode(self, event):
         """!EPSG code selected"""
         winCode = self.FindWindowById(event.GetId())
-        win = self.FindWindowById(self.winId['display:projection:proj4'])
+        win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
         if not self.epsgCodeDict:
             wx.MessageBox(parent=self,
                           message=_("EPSG code %s not found") % event.GetString(),

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2009-07-06 12:08:13 UTC (rev 38283)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2009-07-06 12:19:42 UTC (rev 38284)
@@ -264,13 +264,14 @@
     
     return layers
 
-def Deg2DMS(lon, lat, string = True, hemisphere = True):
+def Deg2DMS(lon, lat, string = True, hemisphere = True, precision = 3):
     """!Convert deg value to dms string
 
     @param lon longitude (x)
     @param lat latitude (y)
     @param string True to return string otherwise tuple
     @param hemisphere print hemisphere
+    @param precision seconds precision
     
     @return DMS string or tuple of values
     @return empty string on error
@@ -309,8 +310,8 @@
         hlon = ''
         hlat = ''
     
-    slat = __ll_parts(flat)
-    slon = __ll_parts(flon)
+    slat = __ll_parts(flat, precision = precision)
+    slon = __ll_parts(flon, precision = precision)
 
     if string:
         return slon + hlon + '; ' + slat + hlat
@@ -331,18 +332,19 @@
     
     return (x, y)
 
-def __ll_parts(value, reverse = False):
+def __ll_parts(value, reverse = False, precision = 3):
     """!Converts deg to d:m:s string
 
     @param value value to be converted
     @param reverse True to convert from d:m:s to deg
-
+    @param precision seconds precision (ignored if reverse is True)
+    
     @return converted value (string/float)
     @return ValueError on error (reverse == True)
     """
     if not reverse:
         if value == 0.0:
-            return '00:00:00.0000'
+            return '%s%.*f' % ('00:00:0', precision, 0.0)
     
         d = int(int(value))
         m = int((value - d) * 60)
@@ -356,9 +358,9 @@
         if s < 0:
             s = '00.0000'
         elif s < 10.0:
-            s = '0%.4f' % s
+            s = '0%.*f' % (precision, s)
         else:
-            s = '%.4f' % s
+            s = '%.*f' % (precision, s)
         
         return str(d) + ':' + m + ':' + s
     else: # -> reverse



More information about the grass-commit mailing list