소스 검색

wxGUI: added option to disable aligning extent to display size

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@47987 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 년 전
부모
커밋
1b816d5917

+ 1 - 0
gui/wxpython/gui_modules/globalvar.py

@@ -110,6 +110,7 @@ MAP_DISPLAY_STATUSBAR_MODE = [_("Coordinates"),
                               _("Comp. region"),
                               _("Show comp. extent"),
                               _("Display mode"),
+                              _("Display resolution"),
                               _("Display geometry"),
                               _("Map scale"),
                               _("Go to"),

+ 29 - 15
gui/wxpython/gui_modules/mapdisp.py

@@ -167,10 +167,19 @@ class MapFrame(wx.Frame):
                                                              "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 "
@@ -730,24 +739,20 @@ class MapFrame(wx.Frame):
         if self.statusbarWin['render'].GetValue():
             self.OnRender(None)
 
-    def OnToggleResolution(self, event):
-        """
-        Use resolution of computation region settings
-        for redering image instead of display resolution
+    def OnToggleUpdateMap(self, event):
+        """!Update display when toggle display mode
         """
         # 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()
 
@@ -859,6 +864,7 @@ class MapFrame(wx.Frame):
         """!Update statusbar content"""
 
         self.statusbarWin['region'].Hide()
+        self.statusbarWin['alignExtent'].Hide()
         self.statusbarWin['resolution'].Hide()
         self.statusbarWin['mapscale'].Hide()
         self.statusbarWin['goto'].Hide()
@@ -965,20 +971,26 @@ class MapFrame(wx.Frame):
             # 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
@@ -1027,7 +1039,7 @@ class MapFrame(wx.Frame):
             # 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',
@@ -1068,7 +1080,7 @@ class MapFrame(wx.Frame):
             # 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:
@@ -1094,6 +1106,7 @@ class MapFrame(wx.Frame):
         """!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']),
@@ -1912,12 +1925,13 @@ class MapFrame(wx.Frame):
         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:

+ 9 - 7
gui/wxpython/gui_modules/mapdisp_window.py

@@ -1637,10 +1637,8 @@ class BufferedWindow(MapWindow, wx.Window):
         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
@@ -1648,9 +1646,13 @@ class BufferedWindow(MapWindow, wx.Window):
             # 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"):

+ 18 - 2
gui/wxpython/gui_modules/preferences.py

@@ -150,6 +150,9 @@ class Settings:
                 'driver': {
                     'type': 'cairo'
                     },
+                'alignExtent' : {
+                    'enabled' : True
+                    },
                 'compResolution' : {
                     'enabled' : False
                     },
@@ -1560,12 +1563,25 @@ class PreferencesDialog(PreferencesBaseDialog):
                       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()
 

+ 16 - 13
gui/wxpython/gui_modules/workspace.py

@@ -155,6 +155,7 @@ class ProcessWorkspaceFile:
                     "pos"            : pos,
                     "size"           : size,
                     "extent"         : extent,
+                    "alignExtent"    : bool(int(display.get('alignExtent', "0"))),
                     "constrainRes"   : bool(int(display.get('constrainRes', "0"))),
                     "projection"     : projection,
                     "viewMode"       : display.get('viewMode', '2d')} )
@@ -910,23 +911,25 @@ class WriteWorkspaceFile(object):
             
             file.write('%s<display render="%d" '
                        'mode="%d" showCompExtent="%d" '
+                       'alignExtent="%d" '
                        'constrainRes="%d" '
                        'dim="%d,%d,%d,%d" '
                        'extent="%f,%f,%f,%f" '
                        'viewMode="%s" >\n' % (' ' * self.indent,
-                                                    int(mapTree.mapdisplay.statusbarWin['render'].IsChecked()),
-                                                    mapTree.mapdisplay.statusbarWin['toggle'].GetSelection(),
-                                                    int(mapTree.mapdisplay.statusbarWin['region'].IsChecked()),
-                                                    int(mapTree.mapdisplay.statusbarWin['resolution'].IsChecked()),
-                                                    displayPos[0],
-                                                    displayPos[1],
-                                                    displaySize[0],
-                                                    displaySize[1],
-                                                    region['w'],
-                                                    region['s'],
-                                                    region['e'],
-                                                    region['n'],
-                                                    viewmode
+                                              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],
+                                              displaySize[0],
+                                              displaySize[1],
+                                              region['w'],
+                                              region['s'],
+                                              region['e'],
+                                              region['n'],
+                                              viewmode
                                                     ))
             # projection statusbar info
             if mapTree.mapdisplay.statusbarWin['projection'].IsChecked() and \

+ 1 - 0
gui/wxpython/wxgui.py

@@ -828,6 +828,7 @@ class GMFrame(wx.Frame):
             mapdisp.SetProperties(render = display['render'],
                                   mode = display['mode'],
                                   showCompExtent = display['showCompExtent'],
+                                  alignExtent = display['alignExtent'],
                                   constrainRes = display['constrainRes'],
                                   projection = display['projection']['enabled'])