[GRASS-SVN] r41217 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 28 07:33:41 EST 2010
Author: martinl
Date: 2010-02-28 07:33:41 -0500 (Sun, 28 Feb 2010)
New Revision: 41217
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: middle-click+drag to pan the map
(merge r41200 & r41216 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2010-02-28 12:27:01 UTC (rev 41216)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py 2010-02-28 12:33:41 UTC (rev 41217)
@@ -14,7 +14,7 @@
Usage:
python mapdisp.py monitor-identifier /path/to/command/file
-(C) 2006-2009 by the GRASS Development Team
+(C) 2006-2010 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.
@@ -1281,11 +1281,15 @@
self.layerbook.DeletePage(pgnum)
def GetRender(self):
- """
+ """!
Returns the current instance of render.Map()
"""
return self.Map
+ def GetWindow(self):
+ """!Get map window"""
+ return self.MapWindow
+
def OnQueryDisplay(self, event):
"""
Query currrent raster/vector map layers (display mode)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py 2010-02-28 12:27:01 UTC (rev 41216)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py 2010-02-28 12:33:41 UTC (rev 41217)
@@ -883,22 +883,21 @@
def DragMap(self, moveto):
"""!
Drag the entire map image for panning.
+
+ @param moveto dx,dy
"""
-
dc = wx.BufferedDC(wx.ClientDC(self))
dc.SetBackground(wx.Brush("White"))
dc.Clear()
-
+
self.dragimg = wx.DragImage(self.buffer)
self.dragimg.BeginDrag((0, 0), self)
self.dragimg.GetImageRect(moveto)
self.dragimg.Move(moveto)
-
+
self.dragimg.DoDrawImage(dc, moveto)
self.dragimg.EndDrag()
-
- return True
-
+
def DragItem(self, id, event):
"""!
Drag an overlay decoration item
@@ -1089,6 +1088,10 @@
elif event.MiddleDown():
self.OnMiddleDown(event)
+ # middle mouse button relesed
+ elif event.MiddleUp():
+ self.OnMiddleUp(event)
+
# right mouse button pressed
elif event.RightDown():
self.OnRightDown(event)
@@ -1099,9 +1102,9 @@
elif event.Moving():
self.OnMouseMoving(event)
-
-# event.Skip()
+ # event.Skip()
+
def OnMouseWheel(self, event):
"""!
Mouse wheel moved
@@ -1115,7 +1118,7 @@
current[1] - self.Map.height / 4)
end = (current[0] + self.Map.width / 4,
current[1] + self.Map.height / 4)
-
+
if wheel > 0:
zoomtype = 1
else:
@@ -1145,19 +1148,20 @@
previous = self.mouse['begin']
move = (current[0] - previous[0],
current[1] - previous[1])
-
+
digitToolbar = self.parent.toolbars['vdigit']
-
+
# dragging or drawing box with left button
- if self.mouse['use'] == 'pan':
+ if self.mouse['use'] == 'pan' or \
+ event.MiddleIsDown():
self.DragMap(move)
-
+
# dragging decoration overlay item
elif (self.mouse['use'] == 'pointer' and
not digitToolbar and
self.dragid != None):
self.DragItem(self.dragid, event)
-
+
# dragging anything else - rubber band box or line
else:
if (self.mouse['use'] == 'pointer' and
@@ -1170,8 +1174,8 @@
digitClass.driver.GetSelected() > 0)):
# draw box only when left mouse button is pressed
self.MouseDraw(pdc=self.pdcTmp)
-
-# event.Skip()
+
+ # event.Skip()
def OnLeftDownVDigitAddLine(self, event):
"""!
@@ -1499,7 +1503,7 @@
self.mouse["use"])
self.mouse['begin'] = event.GetPositionTuple()[:]
-
+
if self.mouse["use"] in ["measure", "profile"]:
# measure or profile
if len(self.polycoords) == 0:
@@ -1846,14 +1850,15 @@
Left mouse button released
"""
Debug.msg (5, "BufferedWindow.OnLeftUp(): use=%s" % \
- self.mouse["use"])
-
+ self.mouse["use"])
+
self.mouse['end'] = event.GetPositionTuple()[:]
-
+
if self.mouse['use'] in ["zoom", "pan"]:
# set region in zoom or pan
begin = self.mouse['begin']
end = self.mouse['end']
+
if self.mouse['use'] == 'zoom':
# set region for click (zero-width box)
if begin[0] - end[0] == 0 or \
@@ -1863,7 +1868,7 @@
end[1] - self.Map.height / 4)
end = (end[0] + self.Map.width / 4,
end[1] + self.Map.height / 4)
-
+
self.Zoom(begin, end, self.zoomtype)
# redraw map
@@ -2231,6 +2236,8 @@
"""!
Middle mouse button pressed
"""
+ self.mouse['begin'] = event.GetPositionTuple()[:]
+
digitToolbar = self.parent.toolbars['vdigit']
# digitization tool
if self.mouse["use"] == "pointer" and digitToolbar:
@@ -2291,7 +2298,25 @@
self.UpdateMap(render=False)
self.redrawAll = True
-
+
+ def OnMiddleUp(self, event):
+ """!
+ Middle mouse button released
+ """
+ self.mouse['end'] = event.GetPositionTuple()[:]
+
+ # set region in zoom or pan
+ begin = self.mouse['begin']
+ end = self.mouse['end']
+
+ self.Zoom(begin, end, 0) # no zoom
+
+ # redraw map
+ self.UpdateMap(render=True)
+
+ # update statusbar
+ self.parent.StatusbarUpdate()
+
def OnMouseMoving(self, event):
"""!
Motion event and no mouse buttons were pressed
@@ -2545,14 +2570,16 @@
"""!
Manages a list of last 10 zoom extents
- Return removed history item if exists
+ @param n,s,e,w north, south, east, west
+
+ @return removed history item if exists (or None)
"""
removed = None
self.zoomhistory.append((n,s,e,w))
-
+
if len(self.zoomhistory) > 10:
removed = self.zoomhistory.pop(0)
-
+
if removed:
Debug.msg(4, "BufferedWindow.ZoomHistory(): hist=%s, removed=%s" %
(self.zoomhistory, removed))
@@ -2560,14 +2587,24 @@
Debug.msg(4, "BufferedWindow.ZoomHistory(): hist=%s" %
(self.zoomhistory))
+ # update toolbar
if len(self.zoomhistory) > 1:
- if self.parent.GetName() == 'MapWindow':
- self.parent.toolbars['map'].Enable('zoomback')
- else:
- self.parent.toolbars['georect'].Enable('zoomback')
+ enable = True
+ else:
+ enable = False
+ if self.parent.GetName() == 'MapWindow':
+ toolbar = self.parent.toolbars['map']
+ elif self.parent.GetName() == 'GRMapWindow':
+ toolbar = self.parent.toolbars['georect']
+ toolbar.Enable('zoomback', enable)
+
return removed
+ def ResetZoomHistory(self):
+ """!Reset zoom history"""
+ self.zoomhistory = list()
+
def OnZoomToMap(self, event):
"""!
Set display extents to match selected raster (including NULLs)
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-02-28 12:27:01 UTC (rev 41216)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2010-02-28 12:33:41 UTC (rev 41217)
@@ -662,17 +662,18 @@
# start map displays first (list of layers can be empty)
#
displayId = 0
- mapdisplay = []
+ mapdisplay = list()
for display in gxwXml.displays:
- mapdisplay.append(self.NewDisplay(show=False))
+ mapdisp = self.NewDisplay(show=False)
+ mapdisplay.append(mapdisp)
maptree = self.gm_cb.GetPage(displayId).maptree
# set windows properties
- mapdisplay[-1].SetProperties(render=display['render'],
- mode=display['mode'],
- showCompExtent=display['showCompExtent'],
- constrainRes=display['constrainRes'],
- projection=display['projection']['enabled'])
+ mapdisp.SetProperties(render=display['render'],
+ mode=display['mode'],
+ showCompExtent=display['showCompExtent'],
+ constrainRes=display['constrainRes'],
+ projection=display['projection']['enabled'])
if display['projection']['enabled']:
if display['projection']['epsg']:
@@ -685,16 +686,21 @@
# set position and size of map display
if UserSettings.Get(group='workspace', key='posDisplay', subkey='enabled') is False:
if display['pos']:
- mapdisplay[-1].SetPosition(display['pos'])
+ mapdisp.SetPosition(display['pos'])
if display['size']:
- mapdisplay[-1].SetSize(display['size'])
+ mapdisp.SetSize(display['size'])
# set extent if defined
if display['extent']:
w, s, e, n = display['extent']
- maptree.Map.region = maptree.Map.GetRegion(w=w, s=s, e=e, n=n)
+ region = maptree.Map.region = maptree.Map.GetRegion(w=w, s=s, e=e, n=n)
+ mapdisp.GetWindow().ResetZoomHistory()
+ mapdisp.GetWindow().ZoomHistory(region['n'],
+ region['s'],
+ region['e'],
+ region['w'])
- mapdisplay[-1].Show()
+ mapdisp.Show()
displayId += 1
@@ -1203,12 +1209,12 @@
@return reference to mapdisplay intance
"""
Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
-
+
# make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
self.pg_panel = wx.Panel(self.gm_cb, id=wx.ID_ANY, style= wx.EXPAND)
self.gm_cb.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx + 1), select = True)
self.curr_page = self.gm_cb.GetCurrentPage()
-
+
# create layer tree (tree control for managing GIS layers) and put on new notebook page
self.curr_page.maptree = wxgui_utils.LayerTree(self.curr_page, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS
@@ -1216,7 +1222,7 @@
|wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE,
idx=self.disp_idx, lmgr=self, notebook=self.gm_cb,
auimgr=self._auimgr, showMapDisplay=show)
-
+
# layout for controls
cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
cb_boxsizer.Add(self.curr_page.maptree, proportion=1, flag=wx.EXPAND, border=1)
@@ -1224,7 +1230,7 @@
cb_boxsizer.Fit(self.curr_page.maptree)
self.curr_page.Layout()
self.curr_page.maptree.Layout()
-
+
# use default window layout
if UserSettings.Get(group='general', key='defWindowPos', subkey='enabled') is True:
dim = UserSettings.Get(group='general', key='defWindowPos', subkey='dim')
@@ -1236,9 +1242,9 @@
self.curr_page.maptree.mapdisplay.SetSize((w, h))
except:
pass
-
+
self.disp_idx += 1
-
+
return self.curr_page.maptree.mapdisplay
# toolBar button handlers
More information about the grass-commit
mailing list