[GRASS-SVN] r52376 - in grass/branches/develbranch_6/gui/wxpython: core gui_core mapdisp nviz psmap

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 16 00:35:41 PDT 2012


Author: annakrat
Date: 2012-07-16 00:35:39 -0700 (Mon, 16 Jul 2012)
New Revision: 52376

Modified:
   grass/branches/develbranch_6/gui/wxpython/core/settings.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
   grass/branches/develbranch_6/gui/wxpython/mapdisp/mapwindow.py
   grass/branches/develbranch_6/gui/wxpython/nviz/mapwindow.py
   grass/branches/develbranch_6/gui/wxpython/psmap/frame.py
Log:
wxGUI: add another option of zoom behaviour - zoom to mouse cursor; used scroll panel for preferences pages (merged from trunk - r52360, r52373)

Modified: grass/branches/develbranch_6/gui/wxpython/core/settings.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/settings.py	2012-07-16 07:03:39 UTC (rev 52375)
+++ grass/branches/develbranch_6/gui/wxpython/core/settings.py	2012-07-16 07:35:39 UTC (rev 52376)
@@ -190,7 +190,9 @@
                     'color' : (255, 255, 255, 255),
                     },
                 'mouseWheelZoom' : {
-                    'enabled' : True,
+                    'selection' : 1,
+                    },
+                'scrollDirection' : {
                     'selection' : 0,
                     },
                 },
@@ -731,8 +733,11 @@
         
         self.internalSettings['display']['driver']['choices'] = ['default']
         self.internalSettings['display']['statusbarMode']['choices'] = None # set during MapFrame init
-        self.internalSettings['display']['mouseWheelZoom']['choices'] = (_('Scroll forward to zoom in'),
-                                                                         _('Scroll back to zoom in'))
+        self.internalSettings['display']['mouseWheelZoom']['choices'] = (_('Zoom and recenter'),
+                                                                         _('Zoom to mouse cursor'),
+                                                                         _('Nothing'))
+        self.internalSettings['display']['scrollDirection']['choices'] = (_('Scroll forward to zoom in'),
+                                                                          _('Scroll back to zoom in'))
 
         self.internalSettings['nviz']['view'] = {}
         self.internalSettings['nviz']['view']['twist'] = {}

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py	2012-07-16 07:03:39 UTC (rev 52375)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py	2012-07-16 07:35:39 UTC (rev 52376)
@@ -39,6 +39,7 @@
 import wx
 import wx.lib.colourselect    as csel
 import wx.lib.mixins.listctrl as listmix
+import wx.lib.scrolledpanel as SP 
 
 from wx.lib.newevent import NewEvent
 
@@ -54,7 +55,7 @@
 class PreferencesBaseDialog(wx.Dialog):
     """!Base preferences dialog"""
     def __init__(self, parent, settings, title = _("User settings"),
-                 size = (500, 375),
+                 size = (500, 425),
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
         self.parent = parent # ModelerFrame
         self.title  = title
@@ -252,7 +253,8 @@
         
     def _createGeneralPage(self, notebook):
         """!Create notebook page for general settings"""
-        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+        panel.SetupScrolling(scroll_x = False, scroll_y = True)
         notebook.AddPage(page = panel, text = _("General"))
         
         border = wx.BoxSizer(wx.VERTICAL)
@@ -382,8 +384,8 @@
 
     def _createAppearancePage(self, notebook):
         """!Create notebook page for display settings"""
-   
-        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+        panel.SetupScrolling(scroll_x = False, scroll_y = True)
         notebook.AddPage(page = panel, text = _("Appearance"))
 
         border = wx.BoxSizer(wx.VERTICAL)
@@ -555,8 +557,8 @@
     
     def _createDisplayPage(self, notebook):
         """!Create notebook page for display settings"""
-   
-        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+        panel.SetupScrolling(scroll_x = False, scroll_y = True)
         notebook.AddPage(page = panel, text = _("Map Display"))
 
         border = wx.BoxSizer(wx.VERTICAL)
@@ -720,26 +722,35 @@
         # mouse wheel zoom
         #
         row += 1
-        wheelZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
-                                  label = _("Enable zooming by mouse wheel"),
-                                  name = "IsChecked")
-        wheelZooming.SetValue(self.settings.Get(group = 'display', key = 'mouseWheelZoom',
-                                                subkey = 'enabled'))
-        self.winId['display:mouseWheelZoom:enabled'] = wheelZooming.GetId()
-
-        gridSizer.Add(item = wheelZooming,
-                      pos = (row, 0), flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
-                      
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                          label = _("Mouse wheel action:")),
+                      flag = wx.ALIGN_LEFT |
+                      wx.ALIGN_CENTER_VERTICAL,
+                      pos = (row, 0))
         listOfModes = self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'choices', internal = True)
-        zoomMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
-                             choices = listOfModes,
-                             name = "GetSelection")
-        zoomMode.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
-        self.winId['display:mouseWheelZoom:selection'] = zoomMode.GetId()
-
-        gridSizer.Add(item = zoomMode,
+        zoomAction = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
+                               choices = listOfModes,
+                               name = "GetSelection")
+        zoomAction.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
+        self.winId['display:mouseWheelZoom:selection'] = zoomAction.GetId()
+        gridSizer.Add(item = zoomAction,
                       flag = wx.ALIGN_RIGHT,
                       pos = (row, 1))
+        row += 1
+        gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+                                          label = _("Mouse scrolling direction:")),
+                      flag = wx.ALIGN_LEFT |
+                      wx.ALIGN_CENTER_VERTICAL,
+                      pos = (row, 0))
+        listOfModes = self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'choices', internal = True)
+        scrollDir = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
+                               choices = listOfModes,
+                               name = "GetSelection")
+        scrollDir.SetSelection(self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'selection'))
+        self.winId['display:scrollDirection:selection'] = scrollDir.GetId()
+        gridSizer.Add(item = scrollDir,
+                      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.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
@@ -748,7 +759,7 @@
                 
         # bindings
         fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
-        wheelZooming.Bind(wx.EVT_CHECKBOX, self.OnEnableWheelZoom)
+        zoomAction.Bind(wx.EVT_CHOICE, self.OnEnableWheelZoom)
         
         # enable/disable controls according to settings
         self.OnEnableWheelZoom(None)
@@ -757,7 +768,8 @@
 
     def _createCmdPage(self, notebook):
         """!Create notebook page for commad dialog settings"""
-        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+        panel.SetupScrolling(scroll_x = False, scroll_y = True)
         notebook.AddPage(page = panel, text = _("Command"))
         
         border = wx.BoxSizer(wx.VERTICAL)
@@ -908,7 +920,8 @@
 
     def _createAttributeManagerPage(self, notebook):
         """!Create notebook page for 'Attribute Table Manager' settings"""
-        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+        panel.SetupScrolling(scroll_x = False, scroll_y = True)
         notebook.AddPage(page = panel, text = _("Attributes"))
 
         pageSizer = wx.BoxSizer(wx.VERTICAL)
@@ -1037,7 +1050,8 @@
 
     def _createProjectionPage(self, notebook):
         """!Create notebook page for workspace settings"""
-        panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+        panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
+        panel.SetupScrolling(scroll_x = False, scroll_y = True)
         notebook.AddPage(page = panel, text = _("Projection"))
         
         border = wx.BoxSizer(wx.VERTICAL)
@@ -1308,10 +1322,14 @@
 
     def OnEnableWheelZoom(self, event):
         """!Enable/disable wheel zoom mode control"""
-        checkId = self.winId['display:mouseWheelZoom:enabled']
         choiceId = self.winId['display:mouseWheelZoom:selection']
-        enable = self.FindWindowById(checkId).IsChecked()
-        self.FindWindowById(choiceId).Enable(enable)
+        choice = self.FindWindowById(choiceId)
+        if choice.GetSelection() == 2:
+            enable = False
+        else:
+            enable = True
+        scrollId = self.winId['display:scrollDirection:selection']
+        self.FindWindowById(scrollId).Enable(enable)
         
 class DefaultFontDialog(wx.Dialog):
     """

Modified: grass/branches/develbranch_6/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/mapdisp/mapwindow.py	2012-07-16 07:03:39 UTC (rev 52375)
+++ grass/branches/develbranch_6/gui/wxpython/mapdisp/mapwindow.py	2012-07-16 07:35:39 UTC (rev 52376)
@@ -937,9 +937,10 @@
     def OnMouseWheel(self, event):
         """!Mouse wheel moved
         """
-        if not UserSettings.Get(group = 'display',
-                                key = 'mouseWheelZoom',
-                                subkey = 'enabled'):
+        zoomBehaviour = UserSettings.Get(group = 'display',
+                                         key = 'mouseWheelZoom',
+                                         subkey = 'selection')
+        if zoomBehaviour == 2:
             event.Skip()
             return
             
@@ -947,11 +948,22 @@
         current  = event.GetPositionTuple()[:]
         wheel = event.GetWheelRotation()
         Debug.msg (5, "BufferedWindow.MouseAction(): wheel=%d" % wheel)
-        # zoom 1/2 of the screen, centered to current mouse position (TODO: settings)
-        begin = (current[0] - self.Map.width / 4,
-                 current[1] - self.Map.height / 4)
-        end   = (current[0] + self.Map.width / 4,
-                 current[1] + self.Map.height / 4)
+        # zoom 1/2 of the screen (TODO: settings)
+        if zoomBehaviour == 0:  # zoom and recenter
+            if wheel > 0:
+                begin = (current[0] - self.Map.width / 4,
+                         current[1] - self.Map.height / 4)
+                end   = (current[0] + self.Map.width / 4,
+                         current[1] + self.Map.height / 4)
+            else:
+                begin = ((self.Map.width - current[0]) / 2,
+                         (self.Map.height - current[1]) / 2)
+                end = (begin[0] + self.Map.width / 2,
+                       begin[1] + self.Map.height / 2)
+        elif zoomBehaviour == 1:  # zoom to current cursor position
+            begin = (current[0]/2, current[1]/2)
+            end = ((self.Map.width - current[0])/2 + current[0],
+                   (self.Map.height - current[1])/2 + current[1])
         
         if wheel > 0:
             zoomtype = 1
@@ -959,7 +971,7 @@
             zoomtype = -1
         
         if UserSettings.Get(group = 'display',
-                            key = 'mouseWheelZoom',
+                            key = 'scrollDirection',
                             subkey = 'selection'):
             zoomtype *= -1
             

Modified: grass/branches/develbranch_6/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/nviz/mapwindow.py	2012-07-16 07:03:39 UTC (rev 52375)
+++ grass/branches/develbranch_6/gui/wxpython/nviz/mapwindow.py	2012-07-16 07:35:39 UTC (rev 52376)
@@ -626,9 +626,9 @@
 
     def OnMouseWheel(self, event):
         """!Change perspective"""
-        if not UserSettings.Get(group = 'display',
-                                key = 'mouseWheelZoom',
-                                subkey = 'enabled'):
+        if UserSettings.Get(group = 'display',
+                            key = 'mouseWheelZoom',
+                            subkey = 'selection') == 2:
             event.Skip()
             return
             
@@ -641,7 +641,7 @@
                 self.ChangeFlySpeed(increase = False)
         else:
             if UserSettings.Get(group = 'display',
-                                key = 'mouseWheelZoom',
+                                key = 'scrollDirection',
                                 subkey = 'selection'):
                 wheel *= -1
             self.DoZoom(zoomtype = wheel, pos = event.GetPositionTuple())

Modified: grass/branches/develbranch_6/gui/wxpython/psmap/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/psmap/frame.py	2012-07-16 07:03:39 UTC (rev 52375)
+++ grass/branches/develbranch_6/gui/wxpython/psmap/frame.py	2012-07-16 07:35:39 UTC (rev 52376)
@@ -1287,9 +1287,9 @@
         """!Mouse wheel scrolled.
 
         Changes zoom."""
-        if not UserSettings.Get(group = 'display',
-                                key = 'mouseWheelZoom',
-                                subkey = 'enabled'):
+        if UserSettings.Get(group = 'display',
+                            key = 'mouseWheelZoom',
+                            subkey = 'selection') == 2:
             event.Skip()
             return
 
@@ -1298,7 +1298,7 @@
         self.mouse['begin'] = event.GetPosition()
         
         if UserSettings.Get(group = 'display',
-                            key = 'mouseWheelZoom',
+                            key = 'scrollDirection',
                             subkey = 'selection'):
             zoom *= -1
             



More information about the grass-commit mailing list