[GRASS-SVN] r57438 - in grass/trunk/gui/wxpython: gcp gui_core iclass mapdisp mapswipe mapwin rlisetup
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 9 01:11:54 PDT 2013
Author: annakrat
Date: 2013-08-09 01:11:54 -0700 (Fri, 09 Aug 2013)
New Revision: 57438
Modified:
grass/trunk/gui/wxpython/gcp/mapdisplay.py
grass/trunk/gui/wxpython/gui_core/mapdisp.py
grass/trunk/gui/wxpython/iclass/frame.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapswipe/frame.py
grass/trunk/gui/wxpython/mapwin/base.py
grass/trunk/gui/wxpython/rlisetup/sampling_frame.py
Log:
wxGUI: setting zoom, pan, pointer mode moved from frame to window
Modified: grass/trunk/gui/wxpython/gcp/mapdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -33,7 +33,6 @@
from core.settings import UserSettings
from mapwin.buffered import BufferedMapWindow
from mapwin.base import MapWindowProperties
-from gui_core.toolbars import ToolSwitcher
import mapdisp.statusbar as sb
import gcp.statusbar as sbgcp
@@ -326,89 +325,27 @@
def OnPointer(self, event):
"""!Pointer button clicked
"""
- # change the cursor
+ self.SrcMapWindow.SetModePointer()
+ self.TgtMapWindow.SetModePointer()
+ # change the default cursor
self.SrcMapWindow.SetNamedCursor('cross')
- self.SrcMapWindow.mouse['use'] = "pointer"
- self.SrcMapWindow.mouse['box'] = "point"
self.TgtMapWindow.SetNamedCursor('cross')
- self.TgtMapWindow.mouse['use'] = "pointer"
- self.TgtMapWindow.mouse['box'] = "point"
def OnZoomIn(self, event):
- """
- Zoom in the map.
- Set mouse cursor, zoombox attributes, and zoom direction
- """
- self.MapWindow.mouse['use'] = "zoom"
- self.MapWindow.mouse['box'] = "box"
- self.MapWindow.zoomtype = 1
- self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
-
- # change the cursor
- self.MapWindow.SetNamedCursor('cross')
+ """Zoom in the map."""
+ self.SrcMapWindow.SetModeZoomIn()
+ self.TgtMapWindow.SetModeZoomIn()
- if self.MapWindow == self.SrcMapWindow:
- win = self.TgtMapWindow
- elif self.MapWindow == self.TgtMapWindow:
- win = self.SrcMapWindow
-
- win.mouse['use'] = "zoom"
- win.mouse['box'] = "box"
- win.zoomtype = 1
- win.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
-
- # change the cursor
- win.SetNamedCursor('cross')
-
def OnZoomOut(self, event):
- """
- Zoom out the map.
- Set mouse cursor, zoombox attributes, and zoom direction
- """
- self.MapWindow.mouse['use'] = "zoom"
- self.MapWindow.mouse['box'] = "box"
- self.MapWindow.zoomtype = -1
- self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
-
- # change the cursor
- self.MapWindow.SetNamedCursor('cross')
+ """Zoom out the map."""
+ self.SrcMapWindow.SetModeZoomOut()
+ self.TgtMapWindow.SetModeZoomOut()
- if self.MapWindow == self.SrcMapWindow:
- win = self.TgtMapWindow
- elif self.MapWindow == self.TgtMapWindow:
- win = self.SrcMapWindow
-
- win.mouse['use'] = "zoom"
- win.mouse['box'] = "box"
- win.zoomtype = -1
- win.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
-
- # change the cursor
- win.SetNamedCursor('cross')
-
def OnPan(self, event):
- """
- Panning, set mouse to drag
- """
- self.MapWindow.mouse['use'] = "pan"
- self.MapWindow.mouse['box'] = "pan"
- self.MapWindow.zoomtype = 0
-
- # change the cursor
- self.MapWindow.SetNamedCursor('hand')
+ """Panning, set mouse to drag"""
+ self.SrcMapWindow.SetModePan()
+ self.TgtMapWindow.SetModePan()
- if self.MapWindow == self.SrcMapWindow:
- win = self.TgtMapWindow
- elif self.MapWindow == self.TgtMapWindow:
- win = self.SrcMapWindow
-
- win.mouse['use'] = "pan"
- win.mouse['box'] = "pan"
- win.zoomtype = 0
-
- # change the cursor
- win.SetNamedCursor('hand')
-
def OnErase(self, event):
"""
Erase the canvas
Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -298,18 +298,12 @@
self.MapWindow.EraseMap()
def OnZoomIn(self, event):
- """!Zoom in the map.
- Set mouse cursor, zoombox attributes, and zoom direction
- """
- win = self.GetWindow()
- self._prepareZoom(mapWindow = win, zoomType = 1)
+ """!Zoom in the map."""
+ self.MapWindow.SetModeZoomIn()
def OnZoomOut(self, event):
- """!Zoom out the map.
- Set mouse cursor, zoombox attributes, and zoom direction
- """
- win = self.GetWindow()
- self._prepareZoom(mapWindow = win, zoomType = -1)
+ """!Zoom out the map."""
+ self.MapWindow.SetModeZoomOut()
def _setUpMapWindow(self, mapWindow):
"""Binds map windows' zoom history signals to map toolbar."""
@@ -322,43 +316,15 @@
self.GetMapToolbar().Enable('zoomBack', enable=False))
mapWindow.mouseMoving.connect(self.CoordinatesChanged)
- def _prepareZoom(self, mapWindow, zoomType):
- """!Prepares MapWindow for zoom, toggles toolbar
-
- @param mapWindow MapWindow to prepare
- @param zoomType 1 for zoom in, -1 for zoom out
- """
- mapWindow.mouse['use'] = "zoom"
- mapWindow.mouse['box'] = "box"
- mapWindow.zoomtype = zoomType
- mapWindow.pen = wx.Pen(colour = 'Red', width = 2, style = wx.SHORT_DASH)
-
- # change the cursor
- mapWindow.SetNamedCursor('cross')
-
def OnPointer(self, event):
"""!Sets mouse mode to pointer."""
- self.MapWindow.mouse['use'] = 'pointer'
- self.MapWindow.mouse['box'] = 'point'
+ self.MapWindow.SetModePointer()
def OnPan(self, event):
"""!Panning, set mouse to drag
"""
- win = self.GetWindow()
- self._preparePan(mapWindow = win)
-
- def _preparePan(self, mapWindow):
- """!Prepares MapWindow for pan, toggles toolbar
-
- @param mapWindow MapWindow to prepare
- """
- mapWindow.mouse['use'] = "pan"
- mapWindow.mouse['box'] = "box"
- mapWindow.zoomtype = 0
-
- # change the cursor
- mapWindow.SetNamedCursor('hand')
-
+ self.MapWindow.SetModePan()
+
def OnZoomBack(self, event):
"""!Zoom last (previously stored position)
"""
@@ -602,42 +568,24 @@
self.Render(mapToRender = self.GetFirstWindow())
def OnZoomIn(self, event):
- """!Zoom in the map.
- Set mouse cursor, zoombox attributes, and zoom direction
- """
- win = self.GetFirstWindow()
- self._prepareZoom(mapWindow = win, zoomType = 1)
-
- win = self.GetSecondWindow()
- self._prepareZoom(mapWindow = win, zoomType = 1)
+ """!Zoom in the map."""
+ self.GetFirstWindow().SetModeZoomIn()
+ self.GetSecondWindow().SetModeZoomIn()
def OnZoomOut(self, event):
- """!Zoom out the map.
- Set mouse cursor, zoombox attributes, and zoom direction
- """
- win = self.GetFirstWindow()
- self._prepareZoom(mapWindow = win, zoomType = -1)
+ """!Zoom out the map."""
+ self.GetFirstWindow().SetModeZoomOut()
+ self.GetSecondWindow().SetModeZoomOut()
- win = self.GetSecondWindow()
- self._prepareZoom(mapWindow = win, zoomType = -1)
-
def OnPan(self, event):
- """!Panning, set mouse to drag
- """
- win = self.GetFirstWindow()
- self._preparePan(mapWindow = win)
-
- win = self.GetSecondWindow()
- self._preparePan(mapWindow = win)
-
+ """!Panning, set mouse to pan"""
+ self.GetFirstWindow().SetModePan()
+ self.GetSecondWindow().SetModePan()
+
def OnPointer(self, event):
"""!Set pointer mode (dragging overlays)"""
- self.GetFirstWindow().mouse['use'] = 'pointer'
- self.GetFirstWindow().mouse['box'] = 'point'
- self.GetFirstWindow().SetNamedCursor('default')
- self.GetSecondWindow().mouse['use'] = 'pointer'
- self.GetSecondWindow().mouse['box'] = 'point'
- self.GetSecondWindow().SetNamedCursor('default')
+ self.GetFirstWindow().SetModePointer()
+ self.GetSecondWindow().SetModePointer()
def OnRender(self, event):
"""!Re-render map composition (each map layer)
Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/iclass/frame.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -53,7 +53,6 @@
from gui_core.dialogs import SetOpacityDialog
from mapwin.base import MapWindowProperties
from dbmgr.vinfo import VectorDBInfo
-from gui_core.toolbars import ToolSwitcher
import grass.script as grass
from iclass.digit import IClassVDigitWindow, IClassVDigit
@@ -1116,10 +1115,9 @@
@todo: pointers need refactoring
"""
- toolbar = self.GetMapToolbar()
+ self.GetFirstWindow().SetModePointer()
+ self.GetSecondWindow().SetModePointer()
- self.GetFirstWindow().mouse['use'] = 'pointer'
-
def OnScatterplot(self, event):
"""!Init interactive scatterplot tools
"""
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -49,7 +49,6 @@
from gui_core.mapdisp import SingleMapFrame
from mapwin.base import MapWindowProperties
from gui_core.query import QueryDialog, PrepareQueryResults
-from gui_core.toolbars import ToolSwitcher
from mapwin.buffered import BufferedMapWindow
from mapwin.decorations import DecorationDialog, TextLayerDialog, \
LegendController, BarscaleController, \
@@ -518,16 +517,12 @@
def OnPointer(self, event):
"""!Pointer button clicked
"""
- self.MapWindow.mouse['use'] = "pointer"
- self.MapWindow.mouse['box'] = "point"
+ self.MapWindow.SetModePointer()
- # change the cursor
if self.GetToolbar('vdigit'):
self.toolbars['vdigit'].action['id'] = -1
self.toolbars['vdigit'].action['desc']=''
- self.MapWindow.SetNamedCursor('default')
-
def OnRotate(self, event):
"""!Rotate 3D view
"""
Modified: grass/trunk/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/frame.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/mapswipe/frame.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -23,7 +23,6 @@
from gui_core.mapdisp import DoubleMapFrame
from gui_core.dialogs import GetImageHandlers
-from gui_core.toolbars import ToolSwitcher
from mapwin.base import MapWindowProperties
from core.render import Map
from mapdisp import statusbar as sb
Modified: grass/trunk/gui/wxpython/mapwin/base.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/base.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/mapwin/base.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -355,3 +355,29 @@
return self._cursor
cursor = property(fget=GetNamedCursor, fset=SetNamedCursor)
+
+ def SetModePointer(self):
+ """!Sets mouse mode to pointer."""
+ self.mouse['use'] = 'pointer'
+ self.mouse['box'] = 'point'
+ self.SetNamedCursor('default')
+
+ def SetModePan(self):
+ """!Sets mouse mode to pan."""
+ self.mouse['use'] = "pan"
+ self.mouse['box'] = "box"
+ self.zoomtype = 0
+ self.SetNamedCursor('hand')
+
+ def SetModeZoomIn(self):
+ self._setModeZoom(zoomType=1)
+
+ def SetModeZoomOut(self):
+ self._setModeZoom(zoomType=-1)
+
+ def _setModeZoom(self, zoomType):
+ self.mouse['use'] = "zoom"
+ self.mouse['box'] = "box"
+ self.zoomtype = zoomType
+ self.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
+ self.SetNamedCursor('cross')
Modified: grass/trunk/gui/wxpython/rlisetup/sampling_frame.py
===================================================================
--- grass/trunk/gui/wxpython/rlisetup/sampling_frame.py 2013-08-08 16:20:37 UTC (rev 57437)
+++ grass/trunk/gui/wxpython/rlisetup/sampling_frame.py 2013-08-09 08:11:54 UTC (rev 57438)
@@ -90,47 +90,18 @@
"""!Returns currently drawn region in a dict"""
return self._region
+ def OnPan(self, event):
+ """!Panning, set mouse to drag."""
+ self.mapWindow.SetModePan()
+
def OnZoomIn(self, event):
- """!Zoom in the map.
- """
- self._prepareZoom(mapWindow=self.mapWindow, zoomType=1)
+ """!Zoom in the map."""
+ self.mapWindow.SetModeZoomIn()
def OnZoomOut(self, event):
- """!Zoom out the map.
- """
- self._prepareZoom(mapWindow=self.mapWindow, zoomType=-1)
+ """!Zoom out the map."""
+ self.mapWindow.SetModeZoomOut()
- def _prepareZoom(self, mapWindow, zoomType):
- """!Prepares MapWindow for zoom
-
- @param mapWindow MapWindow to prepare
- @param zoomType 1 for zoom in, -1 for zoom out
- """
- mapWindow.mouse['use'] = "zoom"
- mapWindow.mouse['box'] = "box"
- mapWindow.zoomtype = zoomType
- mapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
-
- # change the cursor
- mapWindow.SetNamedCursor('cross')
-
- def _onToolChanged(self):
- """!Helper function to disconnect drawing"""
- try:
- self.mapWindow.mouseLeftUp.disconnect(self._rectangleDrawn)
- except DispatcherKeyError:
- pass
-
- def OnPan(self, event):
- """!Panning, set mouse to drag
- """
- self.mapWindow.mouse['use'] = "pan"
- self.mapWindow.mouse['box'] = "pan"
- self.mapWindow.zoomtype = 0
-
- # change the cursor
- self.mapWindow.SetNamedCursor('hand')
-
def OnZoomToMap(self, event):
layers = self.map_.GetListOfLayers()
self.mapWindow.ZoomToMap(layers=layers, ignoreNulls=False, render=True)
@@ -144,6 +115,13 @@
self.mapWindow.mouseLeftUp.connect(self._rectangleDrawn)
+ def _onToolChanged(self):
+ """!Helper function to disconnect drawing"""
+ try:
+ self.mapWindow.mouseLeftUp.disconnect(self._rectangleDrawn)
+ except DispatcherKeyError:
+ pass
+
def _rectangleDrawn(self):
"""!When drawing finished, get region values"""
mouse = self.mapWindow.mouse
More information about the grass-commit
mailing list