[GRASS-SVN] r47988 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 30 16:34:35 EDT 2011


Author: martinl
Date: 2011-08-30 13:34:35 -0700 (Tue, 30 Aug 2011)
New Revision: 47988

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: added option to disable aligning extent to display size
       (merge r47987 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py	2011-08-30 20:24:01 UTC (rev 47987)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py	2011-08-30 20:34:35 UTC (rev 47988)
@@ -110,6 +110,7 @@
                               _("Comp. region"),
                               _("Show comp. extent"),
                               _("Display mode"),
+                              _("Display resolution"),
                               _("Display geometry"),
                               _("Map scale"),
                               _("Go to"),

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2011-08-30 20:24:01 UTC (rev 47987)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2011-08-30 20:34:35 UTC (rev 47988)
@@ -173,10 +173,19 @@
                                                              "computational region, "
                                                              "computational region inside a display region "
                                                              "as a red box).")))
+        # set mode
+        self.statusbarWin['alignExtent'] = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
+                                                       label = _("Align region extent based on display size"))
+        self.statusbarWin['alignExtent'].SetValue(UserSettings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
+        self.statusbarWin['alignExtent'].Hide()
+        self.statusbarWin['alignExtent'].SetToolTip(wx.ToolTip (_("Align region extent based on display "
+                                                                  "size from center point. "
+                                                                  "Default value for new map displays can "
+                                                                  "be set up in 'User GUI settings' dialog.")))
         # set resolution
         self.statusbarWin['resolution'] = wx.CheckBox(parent = self.statusbar, id = wx.ID_ANY,
                                                       label = _("Constrain display resolution to computational settings"))
-        self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.statusbarWin['resolution'])
+        self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleUpdateMap, self.statusbarWin['resolution'])
         self.statusbarWin['resolution'].SetValue(UserSettings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
         self.statusbarWin['resolution'].Hide()
         self.statusbarWin['resolution'].SetToolTip(wx.ToolTip (_("Constrain display resolution "
@@ -715,25 +724,21 @@
         if self.statusbarWin['render'].GetValue():
             self.OnRender(None)
 
-    def OnToggleResolution(self, event):
+    def OnToggleUpdateMap(self, event):
+        """!Update display when toggle display mode
         """
-        Use resolution of computation region settings
-        for redering image instead of display resolution
-        """
         # redraw map if auto-rendering is enabled
         if self.statusbarWin['render'].GetValue():
             self.OnRender(None)
         
     def OnToggleStatus(self, event):
+        """!Toggle status text
         """
-        Toggle status text
-        """
         self.StatusbarUpdate()
 
     def OnChangeMapScale(self, event):
+        """!Map scale changed by user
         """
-        Map scale changed by user
-        """
         scale = event.GetString()
 
         try:
@@ -844,6 +849,7 @@
         """!Update statusbar content"""
 
         self.statusbarWin['region'].Hide()
+        self.statusbarWin['alignExtent'].Hide()
         self.statusbarWin['resolution'].Hide()
         self.statusbarWin['mapscale'].Hide()
         self.statusbarWin['goto'].Hide()
@@ -950,20 +956,26 @@
             # disable long help
             self.StatusbarEnableLongHelp(False)
 
-        elif self.statusbarWin['toggle'].GetSelection() == 4: # Display mode
+        elif self.statusbarWin['toggle'].GetSelection() == 4: # Align extent
             self.statusbar.SetStatusText("", 0)
+            self.statusbarWin['alignExtent'].Show()
+            # disable long help
+            self.StatusbarEnableLongHelp(False)
+
+        elif self.statusbarWin['toggle'].GetSelection() == 5: # Display resolution
+            self.statusbar.SetStatusText("", 0)
             self.statusbarWin['resolution'].Show()
             # disable long help
             self.StatusbarEnableLongHelp(False)
 
-        elif self.statusbarWin['toggle'].GetSelection() == 5: # Display geometry
+        elif self.statusbarWin['toggle'].GetSelection() == 6: # Display geometry
             self.statusbar.SetStatusText("rows=%d; cols=%d; nsres=%.2f; ewres=%.2f" %
                                          (self.Map.region["rows"], self.Map.region["cols"],
                                           self.Map.region["nsres"], self.Map.region["ewres"]), 0)
             # enable long help
             self.StatusbarEnableLongHelp()
 
-        elif self.statusbarWin['toggle'].GetSelection() == 6: # Map scale
+        elif self.statusbarWin['toggle'].GetSelection() == 7: # Map scale
             # TODO: need to be fixed...
             ### screen X region problem
             ### user should specify ppm
@@ -1012,7 +1024,7 @@
             # disable long help
             self.StatusbarEnableLongHelp(False)
 
-        elif self.statusbarWin['toggle'].GetSelection() == 7: # go to
+        elif self.statusbarWin['toggle'].GetSelection() == 8: # go to
             self.statusbar.SetStatusText("")
             region = self.Map.GetCurrentRegion()
             precision = int(UserSettings.Get(group = 'projection', key = 'format',
@@ -1053,7 +1065,7 @@
             # disable long help
             self.StatusbarEnableLongHelp(False)
         
-        elif self.statusbarWin['toggle'].GetSelection() == 8: # projection
+        elif self.statusbarWin['toggle'].GetSelection() == 9: # projection
             self.statusbar.SetStatusText("")
             epsg = UserSettings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')
             if epsg:
@@ -1079,6 +1091,7 @@
         """!Reposition checkbox in statusbar"""
         # reposition checkbox
         widgets = [(0, self.statusbarWin['region']),
+                   (0, self.statusbarWin['alignExtent']),
                    (0, self.statusbarWin['resolution']),
                    (0, self.statusbarWin['mapscale']),
                    (0, self.statusbarWin['progress']),
@@ -1923,12 +1936,13 @@
         zoommenu.Destroy()
         
     def SetProperties(self, render = False, mode = 0, showCompExtent = False,
-                      constrainRes = False, projection = False):
+                      constrainRes = False, projection = False, alignExtent = True):
         """!Set properies of map display window"""
         self.statusbarWin['render'].SetValue(render)
         self.statusbarWin['toggle'].SetSelection(mode)
         self.StatusbarUpdate()
         self.statusbarWin['region'].SetValue(showCompExtent)
+        self.statusbarWin['alignExtent'].SetValue(alignExtent)
         self.statusbarWin['resolution'].SetValue(constrainRes)
         self.statusbarWin['projection'].SetValue(projection)
         if showCompExtent:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2011-08-30 20:24:01 UTC (rev 47987)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2011-08-30 20:34:35 UTC (rev 47988)
@@ -1608,10 +1608,8 @@
         if newreg != {}:
             # LL locations
             if self.parent.Map.projinfo['proj'] == 'll':
-                if newreg['n'] > 90.0:
-                    newreg['n'] = 90.0
-                if newreg['s'] < -90.0:
-                    newreg['s'] = -90.0
+                self.region['n'] = min(self.region['n'], 90.0)
+                self.region['s'] = max(self.region['s'], -90.0)
             
             ce = newreg['w'] + (newreg['e'] - newreg['w']) / 2
             cn = newreg['s'] + (newreg['n'] - newreg['s']) / 2
@@ -1619,9 +1617,13 @@
             # calculate new center point and display resolution
             self.Map.region['center_easting'] = ce
             self.Map.region['center_northing'] = cn
-            self.Map.region["ewres"] = (newreg['e'] - newreg['w']) / self.Map.width
-            self.Map.region["nsres"] = (newreg['n'] - newreg['s']) / self.Map.height
-            self.Map.AlignExtentFromDisplay()
+            self.Map.region['ewres'] = (newreg['e'] - newreg['w']) / self.Map.width
+            self.Map.region['nsres'] = (newreg['n'] - newreg['s']) / self.Map.height
+            if self.parent.statusbarWin['alignExtent'].IsChecked():
+                self.Map.AlignExtentFromDisplay()
+            else:
+                for k in ('n', 's', 'e', 'w'):
+                    self.Map.region[k] = newreg[k]
             
             if hasattr(self, "digit") and \
                     hasattr(self, "moveInfo"):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2011-08-30 20:24:01 UTC (rev 47987)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2011-08-30 20:34:35 UTC (rev 47988)
@@ -150,6 +150,9 @@
                 'driver': {
                     'type': 'default'
                     },
+                'alignExtent' : {
+                    'enabled' : True
+                    },
                 'compResolution' : {
                     'enabled' : False
                     },
@@ -1505,12 +1508,25 @@
                       pos = (row, 1))
         
         #
+        # Align extent to display size
+        #
+        row += 1
+        alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
+                                  label = _("Align region extent based on display size"),
+                                  name = "IsChecked")
+        alignExtent.SetValue(self.settings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
+        self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
+
+        gridSizer.Add(item = alignExtent,
+                      pos = (row, 0), span = (1, 2))
+        
+        #
         # Use computation resolution
         #
         row += 1
         compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
-                                    label = _("Constrain display resolution to computational settings"),
-                                    name = "IsChecked")
+                                     label = _("Constrain display resolution to computational settings"),
+                                     name = "IsChecked")
         compResolution.SetValue(self.settings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
         self.winId['display:compResolution:enabled'] = compResolution.GetId()
 

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py	2011-08-30 20:24:01 UTC (rev 47987)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/workspace.py	2011-08-30 20:34:35 UTC (rev 47988)
@@ -148,6 +148,7 @@
                     "pos"            : pos,
                     "size"           : size,
                     "extent"         : extent,
+                    "alignExtent"    : bool(int(display.get('alignExtent', "0"))),
                     "constrainRes"   : bool(int(display.get('constrainRes', "0"))),
                     "projection"     : projection, } )
             
@@ -697,12 +698,14 @@
             
             file.write('%s<display render="%d" '
                        'mode="%d" showCompExtent="%d" '
+                       'alignExtent="%d" '
                        'constrainRes="%d" '
                        'dim="%d,%d,%d,%d" '
                        'extent="%f,%f,%f,%f">\n' % (' ' * self.indent,
                                                     int(mapTree.mapdisplay.statusbarWin['render'].IsChecked()),
                                                     mapTree.mapdisplay.statusbarWin['toggle'].GetSelection(),
                                                     int(mapTree.mapdisplay.statusbarWin['region'].IsChecked()),
+                                                    int(mapTree.mapdisplay.statusbarWin['alignExtent'].IsChecked()),
                                                     int(mapTree.mapdisplay.statusbarWin['resolution'].IsChecked()),
                                                     displayPos[0],
                                                     displayPos[1],

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-08-30 20:24:01 UTC (rev 47987)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-08-30 20:34:35 UTC (rev 47988)
@@ -788,6 +788,7 @@
             mapdisp.SetProperties(render = display['render'],
                                   mode = display['mode'],
                                   showCompExtent = display['showCompExtent'],
+                                  alignExtent = display['alignExtent'],
                                   constrainRes = display['constrainRes'],
                                   projection = display['projection']['enabled'])
 



More information about the grass-commit mailing list