[GRASS-SVN] r57397 - in grass/trunk/gui/wxpython: gcp gui_core mapdisp nviz vdigit wxplot
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Aug 4 09:37:56 PDT 2013
Author: annakrat
Date: 2013-08-04 09:37:56 -0700 (Sun, 04 Aug 2013)
New Revision: 57397
Modified:
grass/trunk/gui/wxpython/gcp/manager.py
grass/trunk/gui/wxpython/gcp/mapdisplay.py
grass/trunk/gui/wxpython/gui_core/dialogs.py
grass/trunk/gui/wxpython/gui_core/mapdisp.py
grass/trunk/gui/wxpython/gui_core/mapwindow.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapdisp/mapwindow.py
grass/trunk/gui/wxpython/nviz/mapwindow.py
grass/trunk/gui/wxpython/nviz/tools.py
grass/trunk/gui/wxpython/vdigit/toolbars.py
grass/trunk/gui/wxpython/wxplot/base.py
grass/trunk/gui/wxpython/wxplot/histogram.py
grass/trunk/gui/wxpython/wxplot/profile.py
grass/trunk/gui/wxpython/wxplot/scatter.py
Log:
wxGUI: improve map display cursor handling
Modified: grass/trunk/gui/wxpython/gcp/manager.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/manager.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/gcp/manager.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -921,7 +921,7 @@
self.mapwin.mouse["use"] == "pointer"
self.mapwin.zoomtype = 0
self.mapwin.pen = wx.Pen(colour='black', width=2, style=wx.SOLID)
- self.mapwin.SetCursor(self.cursors["cross"])
+ self.mapwin.SetNamedCursor('cross')
self.mapwin = self.TgtMapWindow
@@ -930,7 +930,7 @@
self.mapwin.mouse["use"] == "pointer"
self.mapwin.zoomtype = 0
self.mapwin.pen = wx.Pen(colour='black', width=2, style=wx.SOLID)
- self.mapwin.SetCursor(self.cursors["cross"])
+ self.mapwin.SetNamedCursor('cross')
#
# show new display & draw map
Modified: grass/trunk/gui/wxpython/gcp/mapdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -126,8 +126,8 @@
self.Map = self.SrcMap
self._setUpMapWindow(self.SrcMapWindow)
self._setUpMapWindow(self.TgtMapWindow)
- self.SrcMapWindow.SetCursor(self.cursors["cross"])
- self.TgtMapWindow.SetCursor(self.cursors["cross"])
+ self.SrcMapWindow.SetNamedCursor('cross')
+ self.TgtMapWindow.SetNamedCursor('cross')
# used to switch current map (combo box in toolbar)
self.SrcMapWindow.mouseEntered.connect(
lambda:
@@ -327,10 +327,10 @@
self.toolbars['gcpdisp'].action['desc'] = ''
# change the cursor
- self.SrcMapWindow.SetCursor(self.cursors["cross"])
+ self.SrcMapWindow.SetNamedCursor('cross')
self.SrcMapWindow.mouse['use'] = "pointer"
self.SrcMapWindow.mouse['box'] = "point"
- self.TgtMapWindow.SetCursor(self.cursors["cross"])
+ self.TgtMapWindow.SetNamedCursor('cross')
self.TgtMapWindow.mouse['use'] = "pointer"
self.TgtMapWindow.mouse['box'] = "point"
@@ -348,7 +348,7 @@
self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
# change the cursor
- self.MapWindow.SetCursor(self.cursors["cross"])
+ self.MapWindow.SetNamedCursor('cross')
if self.MapWindow == self.SrcMapWindow:
win = self.TgtMapWindow
@@ -361,7 +361,7 @@
win.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
# change the cursor
- win.SetCursor(self.cursors["cross"])
+ win.SetNamedCursor('cross')
def OnZoomOut(self, event):
"""
@@ -377,7 +377,7 @@
self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
# change the cursor
- self.MapWindow.SetCursor(self.cursors["cross"])
+ self.MapWindow.SetNamedCursor('cross')
if self.MapWindow == self.SrcMapWindow:
win = self.TgtMapWindow
@@ -390,7 +390,7 @@
win.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
# change the cursor
- win.SetCursor(self.cursors["cross"])
+ win.SetNamedCursor('cross')
def OnPan(self, event):
"""
@@ -404,7 +404,7 @@
self.MapWindow.zoomtype = 0
# change the cursor
- self.MapWindow.SetCursor(self.cursors["hand"])
+ self.MapWindow.SetNamedCursor('hand')
if self.MapWindow == self.SrcMapWindow:
win = self.TgtMapWindow
@@ -416,7 +416,7 @@
win.zoomtype = 0
# change the cursor
- win.SetCursor(self.cursors["hand"])
+ win.SetNamedCursor('hand')
def OnErase(self, event):
"""
Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -639,8 +639,8 @@
window = self._giface.GetMapWindow()
if event.GetInt():
self._oldMouseUse = window.mouse['use']
- self._oldCursor = window.GetCursor()
- window.SetCursor(self.parent.cursors["cross"])
+ self._oldCursor = window.GetNamedCursor()
+ window.SetNamedCursor('cross')
window.mouse['use'] = None
window.mouse['box'] = 'box'
window.pen = wx.Pen(colour = 'Black', width = 2, style = wx.SHORT_DASH)
@@ -653,7 +653,7 @@
"""!Restore conditions before resizing"""
window = self._giface.GetMapWindow()
if self._oldCursor:
- window.SetCursor(self._oldCursor)
+ window.SetNamedCursor(self._oldCursor)
if self._oldMouseUse:
window.mouse['use'] = self._oldMouseUse
Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -74,17 +74,6 @@
self.parent = parent
wx.Frame.__init__(self, parent, id, title, style = style, name = name, **kwargs)
-
- # available cursors
- self.cursors = {
- # default: cross
- # "default" : wx.StockCursor(wx.CURSOR_DEFAULT),
- "default" : wx.StockCursor(wx.CURSOR_ARROW),
- "cross" : wx.StockCursor(wx.CURSOR_CROSS),
- "hand" : wx.StockCursor(wx.CURSOR_HAND),
- "pencil" : wx.StockCursor(wx.CURSOR_PENCIL),
- "sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE)
- }
#
# set the size & system icon
@@ -341,7 +330,7 @@
mapWindow.pen = wx.Pen(colour = 'Red', width = 2, style = wx.SHORT_DASH)
# change the cursor
- mapWindow.SetCursor(self.cursors["cross"])
+ mapWindow.SetNamedCursor('cross')
def SwitchTool(self, toolbar, event):
"""!Helper function to switch tools"""
@@ -376,7 +365,7 @@
mapWindow.zoomtype = 0
# change the cursor
- mapWindow.SetCursor(self.cursors["hand"])
+ mapWindow.SetNamedCursor('hand')
def OnZoomBack(self, event):
"""!Zoom last (previously stored position)
@@ -660,9 +649,9 @@
self.SwitchTool(toolbar, event)
self.GetFirstWindow().mouse['use'] = 'pointer'
- self.GetFirstWindow().SetCursor(self.cursors["default"])
+ self.GetFirstWindow().SetNamedCursor('default')
self.GetSecondWindow().mouse['use'] = 'pointer'
- self.GetSecondWindow().SetCursor(self.cursors["default"])
+ self.GetSecondWindow().SetNamedCursor('default')
def OnRender(self, event):
"""!Re-render map composition (each map layer)
Modified: grass/trunk/gui/wxpython/gui_core/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapwindow.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/gui_core/mapwindow.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -145,7 +145,16 @@
wx.EVT_MOUSEWHEEL : [],
wx.EVT_MOUSE_EVENTS : []
}
-
+
+ # available cursors:
+ self._cursors = {
+ "default" : wx.StockCursor(wx.CURSOR_ARROW),
+ "cross" : wx.StockCursor(wx.CURSOR_CROSS),
+ "hand" : wx.StockCursor(wx.CURSOR_HAND),
+ "pencil" : wx.StockCursor(wx.CURSOR_PENCIL),
+ "sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE)
+ }
+
wx.CallAfter(self.InitBinding)
def __del__(self):
@@ -230,8 +239,8 @@
self.mouse['use'] = 'genericEvent'
if cursor:
- self._overriddenCursor = self.GetCursor()
- self.SetCursor(cursor)
+ self._overriddenCursor = self.GetNamedCursor()
+ self.SetNamedCursor(cursor)
return True
@@ -292,7 +301,7 @@
# restore overridden cursor
if self._overriddenCursor:
- self.SetCursor(self._overriddenCursor)
+ self.SetNamedCursor(self._overriddenCursor)
self.mouseHandlerUnregistered.emit()
return True
@@ -325,3 +334,15 @@
@see OnMotion
"""
return self.lastEN
+
+ def SetNamedCursor(self, cursorName):
+ """!Sets cursor defined by name."""
+ cursor = self._cursors[cursorName]
+ self.SetCursor(cursor)
+ self._cursor = cursorName
+
+ def GetNamedCursor(self):
+ """!Returns current cursor name."""
+ return self._cursor
+
+ cursor = property(fget=GetNamedCursor, fset=SetNamedCursor)
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -174,7 +174,7 @@
self._giface.updateMap.connect(self.MapWindow2D.UpdateMap)
# default is 2D display mode
self.MapWindow = self.MapWindow2D
- self.MapWindow.SetCursor(self.cursors["default"])
+ self.MapWindow.SetNamedCursor('default')
# used by vector digitizer
self.MapWindowVDigit = None
# used by Nviz (3D display mode)
@@ -331,7 +331,7 @@
Map = self.Map, tree = self.tree, lmgr = self._layerManager)
self._setUpMapWindow(self.MapWindow3D)
self.MapWindow = self.MapWindow3D
- self.MapWindow.SetCursor(self.cursors["default"])
+ self.MapWindow.SetNamedCursor('default')
# add Nviz notebookpage
self._layerManager.AddNvizTools()
@@ -519,7 +519,7 @@
# change the cursor
if self.GetToolbar('vdigit'):
# digitization tool activated
- self.MapWindow.SetCursor(self.cursors["cross"])
+ self.MapWindow.SetNamedCursor('cross')
# reset mouse['box'] if needed
if self.toolbars['vdigit'].GetAction() in ['addLine']:
@@ -535,7 +535,7 @@
self.MapWindow.mouse['box'] = 'box'
else:
- self.MapWindow.SetCursor(self.cursors["default"])
+ self.MapWindow.SetNamedCursor('default')
def OnRotate(self, event):
"""!Rotate 3D view
@@ -547,7 +547,7 @@
self.MapWindow.mouse['use'] = "rotate"
# change the cursor
- self.MapWindow.SetCursor(self.cursors["hand"])
+ self.MapWindow.SetNamedCursor('hand')
def OnFlyThrough(self, event):
"""!Fly-through mode
@@ -559,7 +559,7 @@
self.MapWindow.mouse['use'] = "fly"
# change the cursor
- self.MapWindow.SetCursor(self.cursors["hand"])
+ self.MapWindow.SetNamedCursor('hand')
self.MapWindow.SetFocus()
def SaveToFile(self, event):
@@ -806,7 +806,7 @@
self.MapWindow.zoomtype = 0
# change the cursor
- self.MapWindow.SetCursor(self.cursors["cross"])
+ self.MapWindow.SetNamedCursor('cross')
def AddTmpVectorMapLayer(self, name, cats, useId = False, addLayer = True):
"""!Add temporal vector map layer to map composition
@@ -879,7 +879,7 @@
self.MapWindow.polypen = wx.Pen(colour = 'green', width = 2, style = wx.SHORT_DASH)
# change the cursor
- self.MapWindow.SetCursor(self.cursors["pencil"])
+ self.MapWindow.SetNamedCursor('pencil')
# initiating output (and write a message)
# e.g., in Layer Manager switch to output console
Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -744,7 +744,7 @@
self.mouse['use'] = 'pointer'
self.mouse['box'] = 'point'
self.mouse['end'] = [0, 0]
- self.SetCursor(self.frame.cursors["default"])
+ self.SetNamedCursor('default')
stop = time.clock()
@@ -1228,7 +1228,7 @@
self.mouse['box'] = 'point'
self.mouse['end'] = [0, 0]
self.Refresh()
- self.SetCursor(self.frame.cursors["default"])
+ self.SetNamedCursor('default')
elif self.mouse["use"] != "profile" or \
(self.mouse['use'] != 'pointer' and \
Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -119,10 +119,7 @@
self.mouse = {
'use': 'pointer'
}
- self.cursors = {
- 'default' : wx.StockCursor(wx.CURSOR_ARROW),
- 'cross' : wx.StockCursor(wx.CURSOR_CROSS),
- }
+
# list of loaded map layers (layer tree items)
self.layers = list()
# list of constant surfaces
@@ -723,7 +720,7 @@
toggle = self.lmgr.nviz.FindWindowByName('here')
toggle.SetValue(False)
self.mouse['use'] = 'pointer'
- self.SetCursor(self.cursors['default'])
+ self.SetNamedCursor('default')
if self.mouse['use'] == 'arrow':
pos = event.GetPosition()
@@ -839,7 +836,7 @@
else:
self.lmgr.nviz.AddArrow()
self.mouse['use'] = 'pointer'
- self.SetCursor(self.cursors['default'])
+ self.SetNamedCursor('default')
elif self.mouse['use'] == 'pointer':
Modified: grass/trunk/gui/wxpython/nviz/tools.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/tools.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/nviz/tools.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -2887,10 +2887,10 @@
if self.FindWindowById(event.GetId()).GetValue():
self.mapDisplay.Raise()
self.mapWindow.mouse['use'] = 'lookHere'
- self.mapWindow.SetCursor(self.mapWindow.cursors["cross"])
+ self.mapWindow.SetNamedCursor('cross')
else:
self.mapWindow.mouse['use'] = 'default'
- self.mapWindow.SetCursor(self.mapWindow.cursors['default'])
+ self.mapWindow.SetNamedCursor('default')
def OnResetView(self, event):
"""!Reset to default view (view page)"""
@@ -4388,10 +4388,10 @@
if event.GetInt():
self.mapDisplay.Raise()
self.mapWindow.mouse['use'] = type
- self.mapWindow.SetCursor(self.mapWindow.cursors["cross"])
+ self.mapWindow.SetNamedCursor('cross')
else:
self.mapWindow.mouse['use'] = 'default'
- self.mapWindow.SetCursor(self.mapWindow.cursors["default"])
+ self.mapWindow.SetNamedCursor('default')
def OnArrowDelete(self, event):
"""!Delete arrow"""
Modified: grass/trunk/gui/wxpython/vdigit/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/toolbars.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/vdigit/toolbars.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -252,8 +252,7 @@
"""!Tool selected -> untoggles previusly selected tool in
toolbar"""
# set cursor
- cursor = self.parent.cursors["cross"]
- self.MapWindow.SetCursor(cursor)
+ self.MapWindow.SetNamedCursor('cross')
# pointer
self.parent.OnPointer(None)
@@ -808,7 +807,7 @@
# change cursor
if self.MapWindow.mouse['use'] == 'pointer':
- self.MapWindow.SetCursor(self.parent.cursors["cross"])
+ self.MapWindow.SetNamedCursor('cross')
if not self.MapWindow.resize:
self.MapWindow.UpdateMap(render = True)
@@ -866,7 +865,7 @@
self.Map.ChangeLayerActive(self.mapLayer, True)
# change cursor
- self.MapWindow.SetCursor(self.parent.cursors["default"])
+ self.MapWindow.SetNamedCursor('default')
self.MapWindow.pdcVector = None
# close dialogs
Modified: grass/trunk/gui/wxpython/wxplot/base.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/base.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/wxplot/base.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -580,6 +580,6 @@
pass
if self.mapwin:
- self.mapwin.SetCursor(self.Parent.cursors["default"])
+ self.mapwin.SetNamedCursor('default')
self.Destroy()
Modified: grass/trunk/gui/wxpython/wxplot/histogram.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/histogram.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/wxplot/histogram.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -74,7 +74,7 @@
plot to create a line graph of the histogram.
"""
try:
- self.SetCursor(self.parent.cursors["default"])
+ self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
except:
pass
Modified: grass/trunk/gui/wxpython/wxplot/profile.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/profile.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/wxplot/profile.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -101,7 +101,7 @@
self.mapwin.mouse['box'] = 'line'
self.mapwin.pen = wx.Pen(colour = 'Red', width = 2, style = wx.SHORT_DASH)
self.mapwin.polypen = wx.Pen(colour = 'dark green', width = 2, style = wx.SHORT_DASH)
- self.mapwin.SetCursor(self.Parent.cursors["cross"])
+ self.mapwin.SetNamedCursor('cross')
def OnSelectRaster(self, event):
"""!Select raster map(s) to profile
@@ -266,8 +266,8 @@
dlg.Destroy()
return
- self.mapwin.SetCursor(self.parent.cursors["default"])
- self.SetCursor(self.parent.cursors["default"])
+ self.mapwin.SetNamedCursor('default')
+ self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
self.SetGraphStyle()
self.SetupProfile()
p = self.CreatePlotList()
Modified: grass/trunk/gui/wxpython/wxplot/scatter.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/scatter.py 2013-08-04 16:13:56 UTC (rev 57396)
+++ grass/trunk/gui/wxpython/wxplot/scatter.py 2013-08-04 16:37:56 UTC (rev 57397)
@@ -72,7 +72,7 @@
create a list of cell value pairs. This is passed to
plot to create a scatterplot.
"""
- self.SetCursor(self.parent.cursors["default"])
+ self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
self.SetGraphStyle()
self.SetupScatterplot()
p = self.CreatePlotList()
More information about the grass-commit
mailing list