[GRASS-SVN] r48765 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 12 12:36:36 EDT 2011
Author: annakrat
Date: 2011-10-12 09:36:36 -0700 (Wed, 12 Oct 2011)
New Revision: 48765
Modified:
grass/trunk/gui/wxpython/gui_modules/gcpmanager.py
grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py
grass/trunk/gui/wxpython/gui_modules/layertree.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: toolbar access methods added (co-author V. Petras)
Modified: grass/trunk/gui/wxpython/gui_modules/gcpmanager.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcpmanager.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/gcpmanager.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -1787,7 +1787,7 @@
def UpdateActive(self, win):
# optionally disable tool zoomback tool
- self.toolbars['gcpdisp'].Enable('zoomback', enable = (len(self.MapWindow.zoomhistory) > 1))
+ self.GetMapToolbar().Enable('zoomback', enable = (len(self.MapWindow.zoomhistory) > 1))
if self.activemap.GetSelection() != (win == self.TgtMapWindow):
self.activemap.SetSelection(win == self.TgtMapWindow)
@@ -1883,7 +1883,7 @@
def OnDispResize(self, event):
"""!GCP Map Display resized, adjust Map Windows
"""
- if self.toolbars['gcpdisp']:
+ if self.GetMapToolbar():
srcwidth, srcheight = self.SrcMapWindow.GetSize()
tgtwidth, tgtheight = self.TgtMapWindow.GetSize()
srcwidth = (srcwidth + tgtwidth) / 2
@@ -2758,7 +2758,7 @@
self.parent.show_target = True
self.parent._mgr.GetPane("target").Show()
self.parent._mgr.Update()
- self.parent.toolbars['gcpdisp'].Enable('zoommenu', enable = True)
+ self.parent.GetMapToolbar().Enable('zoommenu', enable = True)
self.parent.activemap.Enable()
self.parent.TgtMapWindow.ZoomToMap(layers = self.parent.TgtMap.GetListOfLayers())
else: # tgt_map == ''
@@ -2768,7 +2768,7 @@
self.parent._mgr.Update()
self.parent.activemap.SetSelection(0)
self.parent.activemap.Enable(False)
- self.parent.toolbars['gcpdisp'].Enable('zoommenu', enable = False)
+ self.parent.GetMapToolbar().Enable('zoommenu', enable = False)
self.parent.UpdateColours(srcrender, srcrenderVector, tgtrender, tgtrenderVector)
Modified: grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/gcpmapdisp.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -95,12 +95,6 @@
#
# Add toolbars
#
- self.toolbars = { 'map' : None,
- 'vdigit' : None,
- 'gcpdisp' : None,
- 'gcpman' : None,
- 'nviz' : None }
-
for toolb in toolbars:
self.AddToolbar(toolb)
Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -228,7 +228,7 @@
idle time instead of multiple times during layer changing.
"""
if self.rerender:
- if self.mapdisplay.toolbars['vdigit']:
+ if self.mapdisplay.GetToolbar('vdigit'):
vector = True
else:
vector = False
@@ -335,7 +335,7 @@
layer = self.GetPyData(self.layer_selected)[0]['maplayer']
# enable editing only for vector map layers available in the current mapset
- digitToolbar = self.mapdisplay.toolbars['vdigit']
+ digitToolbar = self.mapdisplay.GetToolbar('vdigit')
if digitToolbar:
# background vector map
self.popupMenu.Append(self.popupID['bgmap'],
@@ -605,7 +605,7 @@
dlg.Destroy()
return
- if not self.mapdisplay.toolbars['vdigit']: # enable tool
+ if not self.mapdisplay.GetToolbar('vdigit'): # enable tool
self.mapdisplay.AddToolbar('vdigit')
else: # tool already enabled
pass
@@ -669,8 +669,8 @@
self._getLayerName(self.layer_selected))
# vector layer currently edited
- if self.mapdisplay.toolbars['vdigit'] and \
- self.mapdisplay.toolbars['vdigit'].GetLayer() == maplayer:
+ if self.mapdisplay.GetToolbar('vdigit') and \
+ self.mapdisplay.GetToolbar('vdigit').GetLayer() == maplayer:
alpha = int(new_opacity * 255)
self.mapdisplay.GetWindow().digit.GetDisplay().UpdateSettings(alpha = alpha)
@@ -1084,7 +1084,7 @@
self.rerender = True
self.reorder = True
- if self.mapdisplay.toolbars['vdigit']:
+ if self.mapdisplay.GetToolbar('vdigit'):
self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers (updateTool = True)
# update progress bar range (mapwindow statusbar)
@@ -1115,7 +1115,7 @@
item = event.GetItem()
checked = item.IsChecked()
- digitToolbar = self.mapdisplay.toolbars['vdigit']
+ digitToolbar = self.mapdisplay.GetToolbar('vdigit')
if self.first == False:
# change active parameter for item in layers list in render.Map
if self.GetPyData(item)[0]['type'] == 'group':
@@ -1202,7 +1202,7 @@
event.Veto()
return
- digitToolbar = self.mapdisplay.toolbars['vdigit']
+ digitToolbar = self.mapdisplay.GetToolbar('vdigit')
if digitToolbar:
mapLayer = self.GetPyData(layer)[0]['maplayer']
bgmap = UserSettings.Get(group = 'vdigit', key = 'bgmap', subkey = 'value',
@@ -1566,8 +1566,8 @@
self.GetPyData(item)[0]['maplayer'] = maplayer
# if digitization tool enabled -> update list of available vector map layers
- if self.mapdisplay.toolbars['vdigit']:
- self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers(updateTool = True)
+ if self.mapdisplay.GetToolbar('vdigit'):
+ self.mapdisplay.GetToolbar('vdigit').UpdateListOfLayers(updateTool = True)
# redraw map if auto-rendering is enabled
self.rerender = True
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -116,6 +116,9 @@
self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_map.ico'), wx.BITMAP_TYPE_ICO))
+ # toolbars
+ self.toolbars = {}
+
#
# Fancy gui
#
@@ -251,6 +254,13 @@
"""!Returns toolbar with zooming tools"""
raise NotImplementedError()
+ def GetToolbar(self, name):
+ """!Returns toolbar if exists else None"""
+ if name in self.toolbars:
+ return self.toolbars[name]
+
+ return None
+
def StatusbarUpdate(self):
"""!Update statusbar content"""
self.statusbarManager.Update()
@@ -273,12 +283,16 @@
def StatusbarEnableLongHelp(self, enable = True):
"""!Enable/disable toolbars long help"""
for toolbar in self.toolbars.itervalues():
- if toolbar:
- toolbar.EnableLongHelp(enable)
+ toolbar.EnableLongHelp(enable)
def IsStandalone(self):
"""!Check if Map display is standalone"""
raise NotImplementedError("IsStandalone")
+
+ def OnRender(self, event):
+ """!Re-render map composition (each map layer)
+ """
+ raise NotImplementedError("OnRender")
class MapFrame(MapFrameBase):
"""!Main frame for map display window. Drawing takes place in
@@ -310,12 +324,6 @@
#
# Add toolbars
#
- self.toolbars = { 'map' : None,
- 'vdigit' : None,
- 'gcpdisp' : None,
- 'gcpman' : None,
- 'nviz' : None }
-
for toolb in toolbars:
self.AddToolbar(toolb)
@@ -616,7 +624,7 @@
self._mgr.DetachPane(self.toolbars[name])
self.toolbars[name].Destroy()
- self.toolbars[name] = None
+ self.toolbars.pop(name)
if name == 'vdigit':
self._mgr.GetPane('vdigit').Hide()
@@ -673,7 +681,7 @@
self.MapWindow.ClearLines()
# deselect features in vdigit
- if self.toolbars['vdigit']:
+ if self.GetToolbar('vdigit'):
self.MapWindow.digit.GetDisplay().SetSelected([])
self.MapWindow.UpdateMap(render = True, renderVector = True)
else:
@@ -685,7 +693,7 @@
def OnPointer(self, event):
"""!Pointer button clicked
"""
- if self.toolbars['map']:
+ if self.GetMapToolbar():
if event:
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -694,7 +702,7 @@
self.MapWindow.mouse['box'] = "point"
# change the cursor
- if self.toolbars['vdigit']:
+ if self.GetToolbar('vdigit'):
# digitization tool activated
self.MapWindow.SetCursor(self.cursors["cross"])
@@ -718,7 +726,7 @@
"""!Zoom in the map.
Set mouse cursor, zoombox attributes, and zoom direction
"""
- if self.toolbars['map']:
+ if self.GetMapToolbar():
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -734,7 +742,7 @@
"""!Zoom out the map.
Set mouse cursor, zoombox attributes, and zoom direction
"""
- if self.toolbars['map']:
+ if self.GetMapToolbar():
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -754,7 +762,7 @@
def OnPan(self, event):
"""!Panning, set mouse to drag
"""
- if self.toolbars['map']:
+ if self.GetMapToolbar():
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -768,7 +776,7 @@
def OnRotate(self, event):
"""!Rotate 3D view
"""
- if self.toolbars['map']:
+ if self.GetMapToolbar():
self.toolbars['map'].OnTool(event)
self.toolbars['map'].action['desc'] = ''
@@ -878,7 +886,7 @@
self.Map.Clean()
# close edited map and 3D tools properly
- if self.toolbars['vdigit']:
+ if self.GetToolbar('vdigit'):
maplayer = self.toolbars['vdigit'].GetLayer()
if maplayer:
self.toolbars['vdigit'].OnExit()
@@ -1088,7 +1096,7 @@
def OnQuery(self, event):
"""!Query tools menu"""
- if self.toolbars['map']:
+ if self.GetMapToolbar():
self.toolbars['map'].OnTool(event)
action = self.toolbars['map'].GetAction()
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -40,7 +40,7 @@
style, **kwargs)
self.pdcVector = wx.PseudoDC()
- self.toolbar = self.parent.toolbars['vdigit']
+ self.toolbar = self.parent.GetToolbar('vdigit')
self.digit = None # wxvdigit.IVDigit
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -1318,7 +1318,7 @@
not self.parent.IsStandalone() and \
self.parent.GetLayerManager().gcpmanagement:
# -> GCP manager
- if self.parent.toolbars['gcpdisp']:
+ if self.parent.GetToolbar('gcpdisp'):
coord = self.Pixel2Cell(self.mouse['end'])
if self.parent.MapWindow == self.parent.SrcMapWindow:
coordtype = 'source'
@@ -1444,7 +1444,7 @@
"""
if not self.parent.IsStandalone() and \
self.parent.GetLayerManager().gcpmanagement:
- if self.parent.toolbars['gcpdisp']:
+ if self.parent.GetToolbar('gcpdisp'):
if not self.parent.MapWindow == self:
self.parent.MapWindow = self
self.parent.Map = self.Map
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -657,7 +657,7 @@
# disable tool if stack is empty
if len(self.viewhistory) < 2: # disable tool
- toolbar = self.parent.toolbars['map']
+ toolbar = self.parent.GetMapToolbar()
toolbar.Enable('zoomback', enable = False)
# set view and update nviz view page
@@ -697,7 +697,7 @@
else:
enable = False
- toolbar = self.parent.toolbars['map']
+ toolbar = self.parent.GetMapToolbar()
toolbar.Enable('zoomback', enable)
return removed
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -124,7 +124,7 @@
return
if hasattr(self.parent, 'toolbars'):
- if self.parent.toolbars['vdigit']:
+ if self.parent.GetToolbar('vdigit'):
# update vdigit toolbar (unselect currently selected tool)
id = self.parent.toolbars['vdigit'].GetAction(type = 'id')
self.parent.toolbars['vdigit'].ToggleTool(id, False)
@@ -374,13 +374,13 @@
self.parent.AddNviz()
elif tool == self.toolId['vdigit'] and \
- not self.parent.toolbars['vdigit']:
+ not self.parent.GetToolbar('vdigit'):
self.ExitToolbars()
self.parent.AddToolbar("vdigit")
self.parent.MapWindow.SetFocus()
def ExitToolbars(self):
- if self.parent.toolbars['vdigit']:
+ if self.parent.GetToolbar('vdigit'):
self.parent.toolbars['vdigit'].OnExit()
if self.parent.GetLayerManager().IsPaneShown('toolbarNviz'):
self.parent.RemoveNviz()
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2011-10-12 14:57:57 UTC (rev 48764)
+++ grass/trunk/gui/wxpython/wxgui.py 2011-10-12 16:36:36 UTC (rev 48765)
@@ -500,6 +500,13 @@
"""!Get widget for command output"""
return self.goutput
+ def GetToolbar(self, name):
+ """!Returns toolbar if exists else None"""
+ if name in self.toolbars:
+ return self.toolbars[name]
+
+ return None
+
def GetMenuCmd(self, event):
"""!Get GRASS command from menu item
More information about the grass-commit
mailing list