[GRASS-SVN] r58534 - in grass/trunk/gui/wxpython: core gui_core lmgr mapswipe
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 26 18:30:24 PST 2013
Author: annakrat
Date: 2013-12-26 18:30:24 -0800 (Thu, 26 Dec 2013)
New Revision: 58534
Modified:
grass/trunk/gui/wxpython/core/settings.py
grass/trunk/gui/wxpython/gui_core/preferences.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/mapswipe/dialogs.py
grass/trunk/gui/wxpython/mapswipe/frame.py
grass/trunk/gui/wxpython/mapswipe/mapwindow.py
grass/trunk/gui/wxpython/mapswipe/toolbars.py
Log:
wxGUI/mapswipe: add preferences dialog to change mirrored cursor appearance
Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/core/settings.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -789,6 +789,16 @@
},
},
},
+ 'mapswipe' : {
+ 'cursor': {
+ 'color': (0, 0, 0, 255),
+ 'size': 12,
+ 'width': 1,
+ 'type': {
+ 'selection': 0,
+ }
+ },
+ },
}
# quick fix, http://trac.osgeo.org/grass/ticket/1233
@@ -883,7 +893,12 @@
_("histogram"))
self.internalSettings['vdigit']['bgmap'] = {}
self.internalSettings['vdigit']['bgmap']['value'] = ''
-
+
+ self.internalSettings['mapswipe']['cursor']['type'] = {}
+ self.internalSettings['mapswipe']['cursor']['type']['choices'] = (_("cross"),
+ _("box"),
+ _("circle"))
+
def ReadSettingsFile(self, settings = None):
"""!Reads settings file (mapset, location, gisdbase)"""
if settings is None:
Modified: grass/trunk/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/preferences.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/gui_core/preferences.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -220,34 +220,10 @@
self.settings.Set(group, value, key, [subkey, subkey1])
else:
self.settings.Set(group, value, key, subkey)
-
- if self.parent.GetName() == 'Modeler':
- return True
-
- #
- # update default window dimension
- #
- if self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled') is True:
- dim = ''
- # layer manager
- pos = self.parent.GetPosition()
- size = self.parent.GetSize()
- dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
- # opened displays
- for mapdisp in self._giface.GetAllMapDisplays():
- pos = mapdisp.GetPosition()
- size = mapdisp.GetSize()
- # window size must be larger than zero
- if size[0] > 0 and size[1] > 0:
- dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
+ return True
- self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = dim)
- else:
- self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = '')
- return True
-
class PreferencesDialog(PreferencesBaseDialog):
"""!User preferences dialog"""
def __init__(self, parent, giface, title = _("GUI Settings"),
@@ -1353,6 +1329,33 @@
return panel
+ def _updateSettings(self):
+ if not PreferencesBaseDialog._updateSettings(self):
+ return False
+ #
+ # update default window dimension
+ #
+ if self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled') is True:
+ dim = ''
+ # layer manager
+ pos = self.parent.GetPosition()
+ size = self.parent.GetSize()
+ dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
+ # opened displays
+ for mapdisp in self._giface.GetAllMapDisplays():
+ pos = mapdisp.GetPosition()
+ size = mapdisp.GetSize()
+
+ # window size must be larger than zero
+ if size[0] > 0 and size[1] > 0:
+ dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
+
+ self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = dim)
+ else:
+ self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = '')
+
+ return True
+
def OnCheckColorTable(self, event):
"""!Set/unset default color table"""
win = self.FindWindowById(self.winId['rasterLayer:colorTable:selection'])
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -451,7 +451,7 @@
def OnMapSwipe(self, event):
"""!Launch Map Swipe"""
- win = SwipeMapFrame(parent = self)
+ win = SwipeMapFrame(parent=self, giface=self._giface)
rasters = []
tree = self.GetLayerTree()
Modified: grass/trunk/gui/wxpython/mapswipe/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/dialogs.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/mapswipe/dialogs.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -16,13 +16,17 @@
import copy
import wx
+import wx.lib.scrolledpanel as SP
+import wx.lib.colourselect as csel
-from core import globalvar
+from core import globalvar
from core.utils import _
-from gui_core import gselect
-from gui_core.widgets import SimpleValidator
-from core.gcmd import GMessage
+from gui_core import gselect
+from gui_core.widgets import SimpleValidator
+from gui_core.preferences import PreferencesBaseDialog
+from core.gcmd import GMessage
from core.layerlist import LayerList
+from core.settings import UserSettings
from gui_core.simplelmgr import SimpleLayerManager, SIMPLE_LMGR_RASTER, \
SIMPLE_LMGR_VECTOR, SIMPLE_LMGR_TB_LEFT, SIMPLE_LMGR_TB_RIGHT
@@ -207,3 +211,89 @@
def GetSecondSimpleLmgr(self):
return self._secondLmgr
+
+
+class PreferencesDialog(PreferencesBaseDialog):
+ """!Mapswipe preferences dialog"""
+ def __init__(self, parent, giface, title=_("Map Swipe settings"),
+ settings=UserSettings):
+ PreferencesBaseDialog.__init__(self, parent=parent, giface=giface, title=title,
+ settings=settings, size=(-1, 300))
+
+ # create notebook pages
+ self._createMirrorModePage(self.notebook)
+
+ self.SetMinSize(self.GetBestSize())
+ self.SetSize(self.size)
+
+ def _createMirrorModePage(self, notebook):
+ """!Create notebook page for general settings"""
+ panel = SP.ScrolledPanel(parent=notebook)
+ panel.SetupScrolling(scroll_x=False, scroll_y=True)
+ notebook.AddPage(page=panel, text=_("Mirror mode"))
+
+ border = wx.BoxSizer(wx.VERTICAL)
+ box = wx.StaticBox(parent=panel, label=" %s " % _("Mirrored cursor"))
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+ gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
+
+ row = 0
+ gridSizer.Add(item=wx.StaticText(parent=panel,
+ label=_("Color:")),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+ color = csel.ColourSelect(parent=panel,
+ colour=UserSettings.Get(group='mapswipe',
+ key='cursor', subkey='color'),
+ size=globalvar.DIALOG_COLOR_SIZE)
+ color.SetName('GetColour')
+ self.winId['mapswipe:cursor:color'] = color.GetId()
+
+ gridSizer.Add(item=color, pos=(row, 1), flag=wx.ALIGN_RIGHT)
+
+ row += 1
+ gridSizer.Add(item=wx.StaticText(parent=panel,
+ label=_("Shape:")),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+ cursors = wx.Choice(parent=panel,
+ choices=self.settings.Get(group='mapswipe', key='cursor',
+ subkey=['type', 'choices'], internal=True),
+ name="GetSelection")
+ cursors.SetSelection(self.settings.Get(group='mapswipe', key='cursor',
+ subkey=['type', 'selection']))
+ self.winId['mapswipe:cursor:type:selection'] = cursors.GetId()
+
+ gridSizer.Add(item=cursors, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos=(row, 1))
+
+ row += 1
+ gridSizer.Add(item=wx.StaticText(parent=panel,
+ label=_("Line width:")),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+ width = wx.SpinCtrl(parent=panel, min=1, max=10,
+ initial=self.settings.Get(group='mapswipe', key='cursor',
+ subkey='width'),
+ name="GetValue")
+ self.winId['mapswipe:cursor:width'] = width.GetId()
+
+ gridSizer.Add(item=width, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos=(row, 1))
+
+ row += 1
+ gridSizer.Add(item=wx.StaticText(parent=panel,
+ label=_("Size:")),
+ flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+ size = wx.SpinCtrl(parent=panel, min=4, max=50,
+ initial=self.settings.Get(group='mapswipe', key='cursor',
+ subkey='size'),
+ name="GetValue")
+ self.winId['mapswipe:cursor:size'] = size.GetId()
+
+ gridSizer.Add(item=size, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos=(row, 1))
+
+ gridSizer.AddGrowableCol(1)
+ sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3)
+ border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
+ panel.SetSizer(border)
+
+ return panel
Modified: grass/trunk/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/frame.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/mapswipe/frame.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -33,7 +33,7 @@
from mapswipe.toolbars import SwipeMapToolbar, SwipeMainToolbar, SwipeMiscToolbar
from mapswipe.mapwindow import SwipeBufferedWindow
-from mapswipe.dialogs import SwipeMapDialog
+from mapswipe.dialogs import SwipeMapDialog, PreferencesDialog
class SwipeMapFrame(DoubleMapFrame):
@@ -99,6 +99,7 @@
self.rasters = {'first': None, 'second': None}
self._inputDialog = None
+ self._preferencesDialog = None
# default action in map toolbar
self.GetMapToolbar().SelectDefault()
@@ -117,9 +118,9 @@
return
coords = event.GetPosition()
if showInFirst:
- self.firstMapWindow.DrawMouseCross(coords = coords)
+ self.firstMapWindow.DrawMouseCursor(coords=coords)
else:
- self.secondMapWindow.DrawMouseCross(coords = coords)
+ self.secondMapWindow.DrawMouseCursor(coords=coords)
event.Skip()
@@ -612,6 +613,14 @@
def OnHelp(self, event):
self._giface.Help(entry = 'wxGUI.mapswipe')
+ def OnPreferences(self, event):
+ if not self._preferencesDialog:
+ dlg = PreferencesDialog(parent=self, giface=self._giface)
+ self._preferencesDialog = dlg
+ self._preferencesDialog.CenterOnParent()
+
+ self._preferencesDialog.ShowModal()
+
def OnCloseWindow(self, event):
self.GetFirstMap().Clean()
self.GetSecondMap().Clean()
Modified: grass/trunk/gui/wxpython/mapswipe/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/mapwindow.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/mapswipe/mapwindow.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -21,6 +21,7 @@
from core.debug import Debug
from core.utils import _
+from core.settings import UserSettings
from mapwin.buffered import BufferedMapWindow
@@ -182,10 +183,25 @@
end = (self.mouse['end'][0] + offsetX, self.mouse['end'][1] + offsetY)
super(SwipeBufferedWindow, self).MouseDraw(pdc, begin, end)
- def DrawMouseCross(self, coords):
+ def DrawMouseCursor(self, coords):
"""!Draw moving cross."""
self.pdcTmp.ClearId(self.lineid)
- self.lineid = self.DrawCross(pdc = self.pdcTmp, coords = coords, size = 10, pen = wx.BLACK_PEN)
+ color = UserSettings.Get(group='mapswipe', key='cursor', subkey='color')
+ cursType = UserSettings.Get(group='mapswipe', key='cursor', subkey=['type', 'selection'])
+ size = UserSettings.Get(group='mapswipe', key='cursor', subkey='size')
+ width = UserSettings.Get(group='mapswipe', key='cursor', subkey='width')
+ if cursType == 0:
+ self.lineid = self.DrawCross(pdc=self.pdcTmp, coords=coords, size=size,
+ pen=wx.Pen(wx.Colour(*color), width))
+ elif cursType == 1:
+ self.lineid = self.DrawRectangle(pdc=self.pdcTmp,
+ point1=(coords[0] - size / 2, coords[1] - size / 2),
+ point2=(coords[0] + size / 2, coords[1] + size / 2),
+ pen=wx.Pen(wx.Colour(*color), width))
+ elif cursType == 2:
+ self.lineid = self.DrawCircle(pdc=self.pdcTmp,
+ coords=coords, radius=size / 2,
+ pen=wx.Pen(wx.Colour(*color), width))
class _MouseEvent(wx.PyCommandEvent):
Modified: grass/trunk/gui/wxpython/mapswipe/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/toolbars.py 2013-12-27 02:24:42 UTC (rev 58533)
+++ grass/trunk/gui/wxpython/mapswipe/toolbars.py 2013-12-27 02:30:24 UTC (rev 58534)
@@ -165,8 +165,10 @@
def _toolbarData(self):
"""!Toolbar data"""
- return self._getToolbarData((("help", BaseIcons['help'],
+ return self._getToolbarData((("settings", BaseIcons['settings'],
+ self.parent.OnPreferences),
+ ("help", BaseIcons['help'],
self.parent.OnHelp),
- ("quit", swipeIcons['quit'],
+ ("quit", swipeIcons['quit'],
self.parent.OnCloseWindow),
))
More information about the grass-commit
mailing list