Sfoglia il codice sorgente

wxGUI: add 'Align region to resolution' option to preferences

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70243 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 8 anni fa
parent
commit
0e2e460daf

+ 7 - 1
gui/wxpython/core/settings.py

@@ -11,7 +11,7 @@ Usage:
 from core.settings import UserSettings
 @endcode
 
-(C) 2007-2016 by the GRASS Development Team
+(C) 2007-2017 by the GRASS Development Team
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
 
@@ -104,6 +104,12 @@ class Settings:
                         'enabled': False
                     },
                 },
+                # region
+                'region': {
+                    'resAlign': {
+                        'enabled' : False
+                    },
+                },
             },
             'manager': {
                 # show opacity level widget

+ 37 - 2
gui/wxpython/gui_core/preferences.py

@@ -14,7 +14,7 @@ Classes:
  - preferences::MapsetAccess
  - preferences::CheckListMapset
 
-(C) 2007-2014 by the GRASS Development Team
+(C) 2007-2017 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -57,7 +57,7 @@ class PreferencesBaseDialog(wx.Dialog):
     """Base preferences dialog"""
 
     def __init__(self, parent, giface, settings, title=_("User settings"),
-                 size=(500, 475),
+                 size=(-1, 500),
                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
         self.parent = parent  # ModelerFrame
         self.title = title
@@ -453,6 +453,41 @@ class PreferencesDialog(PreferencesBaseDialog):
             border=5)
         border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
 
+        #
+        # region
+        #
+        box = wx.StaticBox(
+            parent=panel,
+            id=wx.ID_ANY,
+            label=" %s " %
+            _("Region settings"))
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
+
+        row = 0
+        resAlign = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
+            "Align region to resolution"), name='IsChecked')
+        resAlign.SetValue(
+            self.settings.Get(
+                group='general',
+                key='region',
+                subkey=[
+                    'resAlign',
+                    'enabled']))
+        self.winId['general:region:resAlign:enabled'] = resAlign.GetId()
+
+        gridSizer.Add(resAlign,
+                      pos=(row, 0), span=(1, 2))
+
+        gridSizer.AddGrowableCol(0)
+        sizer.Add(
+            gridSizer,
+            proportion=1,
+            flag=wx.ALL | wx.EXPAND,
+            border=5)
+        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
+
         panel.SetSizer(border)
 
         return panel

+ 3 - 0
gui/wxpython/lmgr/layertree.py

@@ -928,6 +928,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
 
         # print output to command log area
         if kwargs:
+            if UserSettings.Get(group='general',
+                                key='region', subkey=['resAlign', 'enabled']):
+                kwargs['flags'] = 'a'
             # command must run in main thread otherwise it can be
             # launched after rendering is done (region extent will
             # remain untouched)