|
@@ -8,7 +8,7 @@ Classes:
|
|
|
- Layer
|
|
|
- LayerTree
|
|
|
|
|
|
-(C) 2007-2010 by the GRASS Development Team
|
|
|
+(C) 2007-2011 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.
|
|
@@ -64,7 +64,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
"""!Creates layer tree structure
|
|
|
"""
|
|
|
def __init__(self, parent,
|
|
|
- id = wx.ID_ANY, style=wx.SUNKEN_BORDER,
|
|
|
+ id = wx.ID_ANY, style = wx.SUNKEN_BORDER,
|
|
|
ctstyle = CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
|
|
|
CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT |
|
|
|
CT.TR_MULTIPLE, **kwargs):
|
|
@@ -105,18 +105,17 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
# self.SetAutoLayout(True)
|
|
|
self.SetGradientStyle(1)
|
|
|
self.EnableSelectionGradient(True)
|
|
|
- self.SetFirstGradientColour(wx.Colour(100, 100, 100))
|
|
|
- self.SetSecondGradientColour(wx.Colour(150, 150, 150))
|
|
|
+ self._setGradient()
|
|
|
|
|
|
# init associated map display
|
|
|
pos = wx.Point((self.disp_idx + 1) * 25, (self.disp_idx + 1) * 25)
|
|
|
self.mapdisplay = mapdisp.MapFrame(self,
|
|
|
- id=wx.ID_ANY, pos=pos,
|
|
|
- size=globalvar.MAP_WINDOW_SIZE,
|
|
|
- style=wx.DEFAULT_FRAME_STYLE,
|
|
|
- tree=self, notebook=self.notebook,
|
|
|
- lmgr=self.lmgr, page=self.treepg,
|
|
|
- Map=self.Map, auimgr=self.auimgr)
|
|
|
+ id = wx.ID_ANY, pos = pos,
|
|
|
+ size = globalvar.MAP_WINDOW_SIZE,
|
|
|
+ style = wx.DEFAULT_FRAME_STYLE,
|
|
|
+ tree = self, notebook = self.notebook,
|
|
|
+ lmgr = self.lmgr, page = self.treepg,
|
|
|
+ Map = self.Map, auimgr = self.auimgr)
|
|
|
|
|
|
# title
|
|
|
self.mapdisplay.SetTitle(_("GRASS GIS Map Display: %(id)d - Location: %(loc)s") % \
|
|
@@ -133,7 +132,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
self.SetPyData(self.root, (None, None))
|
|
|
|
|
|
#create image list to use with layer tree
|
|
|
- il = wx.ImageList(16, 16, mask=False)
|
|
|
+ il = wx.ImageList(16, 16, mask = False)
|
|
|
|
|
|
trart = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN, wx.ART_OTHER, (16, 16))
|
|
|
self.folder_open = il.Add(trart)
|
|
@@ -199,6 +198,21 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnRenamed)
|
|
|
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
|
|
|
self.Bind(wx.EVT_IDLE, self.OnIdle)
|
|
|
+
|
|
|
+ def _setGradient(self, iType = None):
|
|
|
+ """!Set gradient for items
|
|
|
+
|
|
|
+ @param iType bgmap, vdigit or None
|
|
|
+ """
|
|
|
+ if iType == 'bgmap':
|
|
|
+ self.SetFirstGradientColour(wx.Colour(0, 100, 0))
|
|
|
+ self.SetSecondGradientColour(wx.Colour(0, 150, 0))
|
|
|
+ elif iType == 'vdigit':
|
|
|
+ self.SetFirstGradientColour(wx.Colour(100, 0, 0))
|
|
|
+ self.SetSecondGradientColour(wx.Colour(150, 0, 0))
|
|
|
+ else:
|
|
|
+ self.SetFirstGradientColour(wx.Colour(100, 100, 100))
|
|
|
+ self.SetSecondGradientColour(wx.Colour(150, 150, 150))
|
|
|
|
|
|
def GetMap(self):
|
|
|
"""!Get map instace"""
|
|
@@ -215,7 +229,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
"""
|
|
|
if self.rerender:
|
|
|
if self.mapdisplay.statusbarWin['render'].GetValue():
|
|
|
- self.mapdisplay.MapWindow.UpdateMap(render=True)
|
|
|
+ self.mapdisplay.MapWindow.UpdateMap(render = True)
|
|
|
|
|
|
event.Skip()
|
|
|
|
|
@@ -263,12 +277,12 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
numSelected = len(self.GetSelections())
|
|
|
|
|
|
# general item
|
|
|
- self.popupMenu.Append(self.popupID1, text=_("Remove"))
|
|
|
- self.Bind(wx.EVT_MENU, self.lmgr.OnDeleteLayer, id=self.popupID1)
|
|
|
+ self.popupMenu.Append(self.popupID1, text = _("Remove"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.lmgr.OnDeleteLayer, id = self.popupID1)
|
|
|
|
|
|
if ltype != "command": # rename
|
|
|
- self.popupMenu.Append(self.popupID2, text=_("Rename"))
|
|
|
- self.Bind(wx.EVT_MENU, self.OnRenameLayer, id=self.popupID2)
|
|
|
+ self.popupMenu.Append(self.popupID2, text = _("Rename"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnRenameLayer, id = self.popupID2)
|
|
|
if numSelected > 1:
|
|
|
self.popupMenu.Enable(self.popupID2, False)
|
|
|
|
|
@@ -276,20 +290,20 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
if ltype != "group" and \
|
|
|
ltype != "command":
|
|
|
self.popupMenu.AppendSeparator()
|
|
|
- self.popupMenu.Append(self.popupID8, text=_("Change opacity level"))
|
|
|
- self.Bind(wx.EVT_MENU, self.OnPopupOpacityLevel, id=self.popupID8)
|
|
|
- self.popupMenu.Append(self.popupID3, text=_("Properties"))
|
|
|
- self.Bind(wx.EVT_MENU, self.OnPopupProperties, id=self.popupID3)
|
|
|
+ self.popupMenu.Append(self.popupID8, text = _("Change opacity level"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnPopupOpacityLevel, id = self.popupID8)
|
|
|
+ self.popupMenu.Append(self.popupID3, text = _("Properties"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnPopupProperties, id = self.popupID3)
|
|
|
|
|
|
if ltype in ('raster', 'vector', '3d-raster') and self.mapdisplay.toolbars['nviz']:
|
|
|
self.popupMenu.Append(self.popupID11, _("3D view properties"))
|
|
|
- self.Bind (wx.EVT_MENU, self.OnNvizProperties, id=self.popupID11)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnNvizProperties, id = self.popupID11)
|
|
|
|
|
|
if ltype in ('raster', 'vector', 'rgb'):
|
|
|
- self.popupMenu.Append(self.popupID9, text=_("Zoom to selected map(s)"))
|
|
|
- self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToMap, id=self.popupID9)
|
|
|
- self.popupMenu.Append(self.popupID10, text=_("Set computational region from selected map(s)"))
|
|
|
- self.Bind(wx.EVT_MENU, self.OnSetCompRegFromMap, id=self.popupID10)
|
|
|
+ self.popupMenu.Append(self.popupID9, text = _("Zoom to selected map(s)"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToMap, id = self.popupID9)
|
|
|
+ self.popupMenu.Append(self.popupID10, text = _("Set computational region from selected map(s)"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnSetCompRegFromMap, id = self.popupID10)
|
|
|
if numSelected > 1:
|
|
|
self.popupMenu.Enable(self.popupID8, False)
|
|
|
self.popupMenu.Enable(self.popupID3, False)
|
|
@@ -304,14 +318,14 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
#
|
|
|
if mltype and mltype == "vector":
|
|
|
self.popupMenu.AppendSeparator()
|
|
|
- self.popupMenu.Append(self.popupID4, text=_("Show attribute data"))
|
|
|
- self.Bind (wx.EVT_MENU, self.lmgr.OnShowAttributeTable, id=self.popupID4)
|
|
|
+ self.popupMenu.Append(self.popupID4, text = _("Show attribute data"))
|
|
|
+ self.Bind (wx.EVT_MENU, self.lmgr.OnShowAttributeTable, id = self.popupID4)
|
|
|
|
|
|
- self.popupMenu.Append(self.popupID5, text=_("Start editing"))
|
|
|
- self.popupMenu.Append(self.popupID6, text=_("Stop editing"))
|
|
|
+ self.popupMenu.Append(self.popupID5, text = _("Start editing"))
|
|
|
+ self.popupMenu.Append(self.popupID6, text = _("Stop editing"))
|
|
|
self.popupMenu.Enable(self.popupID6, False)
|
|
|
- self.Bind (wx.EVT_MENU, self.OnStartEditing, id=self.popupID5)
|
|
|
- self.Bind (wx.EVT_MENU, self.OnStopEditing, id=self.popupID6)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnStartEditing, id = self.popupID5)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnStopEditing, id = self.popupID6)
|
|
|
|
|
|
layer = self.GetPyData(self.layer_selected)[0]['maplayer']
|
|
|
# enable editing only for vector map layers available in the current mapset
|
|
@@ -319,15 +333,15 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
if digitToolbar:
|
|
|
# background vector map
|
|
|
self.popupMenu.Append(self.popupID14,
|
|
|
- text=_("Use as background vector map"),
|
|
|
- kind=wx.ITEM_CHECK)
|
|
|
- self.Bind(wx.EVT_MENU, self.OnSetBgMap, id=self.popupID14)
|
|
|
- if UserSettings.Get(group='vdigit', key='bgmap', subkey='value',
|
|
|
- internal=True) == layer.GetName():
|
|
|
+ text = _("Use as background vector map for digitizer"),
|
|
|
+ kind = wx.ITEM_CHECK)
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnSetBgMap, id = self.popupID14)
|
|
|
+ if UserSettings.Get(group = 'vdigit', key = 'bgmap', subkey = 'value',
|
|
|
+ internal = True) == layer.GetName():
|
|
|
self.popupMenu.Check(self.popupID14, True)
|
|
|
|
|
|
- self.popupMenu.Append(self.popupID16, text=_("Rebuild topology"))
|
|
|
- self.Bind(wx.EVT_MENU, self.OnTopology, id=self.popupID16)
|
|
|
+ self.popupMenu.Append(self.popupID16, text = _("Rebuild topology"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnTopology, id = self.popupID16)
|
|
|
|
|
|
if layer.GetMapset() != grass.gisenv()['MAPSET']:
|
|
|
# only vector map in current mapset can be edited
|
|
@@ -357,7 +371,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
self.popupMenu.Enable(self.popupID14, True)
|
|
|
|
|
|
self.popupMenu.Append(self.popupID7, _("Metadata"))
|
|
|
- self.Bind (wx.EVT_MENU, self.OnMetadata, id=self.popupID7)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnMetadata, id = self.popupID7)
|
|
|
if numSelected > 1:
|
|
|
self.popupMenu.Enable(self.popupID4, False)
|
|
|
self.popupMenu.Enable(self.popupID5, False)
|
|
@@ -369,19 +383,19 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
# raster layers (specific items)
|
|
|
#
|
|
|
elif mltype and mltype == "raster":
|
|
|
- self.popupMenu.Append(self.popupID12, text=_("Zoom to selected map(s) (ignore NULLs)"))
|
|
|
- self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToRaster, id=self.popupID12)
|
|
|
- self.popupMenu.Append(self.popupID13, text=_("Set computational region from selected map(s) (ignore NULLs)"))
|
|
|
- self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id=self.popupID13)
|
|
|
+ self.popupMenu.Append(self.popupID12, text = _("Zoom to selected map(s) (ignore NULLs)"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToRaster, id = self.popupID12)
|
|
|
+ self.popupMenu.Append(self.popupID13, text = _("Set computational region from selected map(s) (ignore NULLs)"))
|
|
|
+ self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id = self.popupID13)
|
|
|
self.popupMenu.AppendSeparator()
|
|
|
self.popupMenu.Append(self.popupID15, _("Set color table"))
|
|
|
- self.Bind (wx.EVT_MENU, self.OnColorTable, id=self.popupID15)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnColorTable, id = self.popupID15)
|
|
|
self.popupMenu.Append(self.popupID4, _("Histogram"))
|
|
|
- self.Bind (wx.EVT_MENU, self.OnHistogram, id=self.popupID4)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnHistogram, id = self.popupID4)
|
|
|
self.popupMenu.Append(self.popupID5, _("Profile"))
|
|
|
- self.Bind (wx.EVT_MENU, self.OnProfile, id=self.popupID5)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnProfile, id = self.popupID5)
|
|
|
self.popupMenu.Append(self.popupID6, _("Metadata"))
|
|
|
- self.Bind (wx.EVT_MENU, self.OnMetadata, id=self.popupID6)
|
|
|
+ self.Bind (wx.EVT_MENU, self.OnMetadata, id = self.popupID6)
|
|
|
|
|
|
if numSelected > 1:
|
|
|
self.popupMenu.Enable(self.popupID12, False)
|
|
@@ -417,7 +431,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
cmd.append('map=%s' % mapLayer.GetName())
|
|
|
|
|
|
# print output to command log area
|
|
|
- self.lmgr.goutput.RunCmd(cmd, switchPage=True)
|
|
|
+ self.lmgr.goutput.RunCmd(cmd, switchPage = True)
|
|
|
|
|
|
def OnSetCompRegFromRaster(self, event):
|
|
|
"""!Set computational region from selected raster map (ignore NULLs)"""
|
|
@@ -466,10 +480,10 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
"""!Plot profile of given raster map layer"""
|
|
|
mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
|
|
|
if not mapLayer.GetName():
|
|
|
- wx.MessageBox(parent=self,
|
|
|
- message=_("Unable to create profile of "
|
|
|
+ wx.MessageBox(parent = self,
|
|
|
+ message = _("Unable to create profile of "
|
|
|
"raster map."),
|
|
|
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
|
|
|
+ caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
|
|
|
return False
|
|
|
|
|
|
if not hasattr (self, "profileFrame"):
|
|
@@ -480,8 +494,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
if not self.profileFrame:
|
|
|
self.profileFrame = profile.ProfileFrame(self.mapdisplay,
|
|
|
- id=wx.ID_ANY, pos=wx.DefaultPosition, size=(700,300),
|
|
|
- style=wx.DEFAULT_FRAME_STYLE, rasterList=[mapLayer.GetName()])
|
|
|
+ id = wx.ID_ANY, pos = wx.DefaultPosition, size = (700,300),
|
|
|
+ style = wx.DEFAULT_FRAME_STYLE, rasterList = [mapLayer.GetName()])
|
|
|
# show new display
|
|
|
self.profileFrame.Show()
|
|
|
|
|
@@ -499,10 +513,10 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
"""
|
|
|
mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
|
|
|
if not mapLayer.GetName():
|
|
|
- wx.MessageBox(parent=self,
|
|
|
- message=_("Unable to display histogram of "
|
|
|
+ wx.MessageBox(parent = self,
|
|
|
+ message = _("Unable to display histogram of "
|
|
|
"raster map."),
|
|
|
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
|
|
|
+ caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
|
|
|
return False
|
|
|
|
|
|
if not hasattr (self, "histogramFrame"):
|
|
@@ -513,9 +527,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
if not self.histogramFrame:
|
|
|
self.histogramFrame = histogram.HistFrame(self,
|
|
|
- id=wx.ID_ANY,
|
|
|
- pos=wx.DefaultPosition, size=globalvar.HIST_WINDOW_SIZE,
|
|
|
- style=wx.DEFAULT_FRAME_STYLE)
|
|
|
+ id = wx.ID_ANY,
|
|
|
+ pos = wx.DefaultPosition, size = globalvar.HIST_WINDOW_SIZE,
|
|
|
+ style = wx.DEFAULT_FRAME_STYLE)
|
|
|
self.histogramFrame.CentreOnScreen()
|
|
|
# show new display
|
|
|
self.histogramFrame.Show()
|
|
@@ -549,7 +563,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
style = wx.YES_NO | wx.CENTRE)
|
|
|
if dlg.ShowModal() == wx.ID_YES:
|
|
|
self.lmgr.goutput.RunCmd(['v.digit', 'map=%s' % maplayer.GetName()],
|
|
|
- switchPage=False)
|
|
|
+ switchPage = False)
|
|
|
|
|
|
dlg.Destroy()
|
|
|
return
|
|
@@ -560,27 +574,38 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
pass
|
|
|
|
|
|
# mark layer as 'edited'
|
|
|
- self.mapdisplay.toolbars['vdigit'].StartEditing (maplayer)
|
|
|
-
|
|
|
+ self.mapdisplay.toolbars['vdigit'].StartEditing(maplayer)
|
|
|
+
|
|
|
+ self._setGradient('vdigit')
|
|
|
+ self.RefreshLine(self.layer_selected)
|
|
|
+
|
|
|
def OnStopEditing(self, event):
|
|
|
- """
|
|
|
- Stop editing the current vector map layer
|
|
|
+ """!Stop editing the current vector map layer
|
|
|
"""
|
|
|
maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
|
|
|
|
|
|
self.mapdisplay.toolbars['vdigit'].OnExit()
|
|
|
self.mapdisplay.imgVectorMap = None
|
|
|
|
|
|
+ self._setGradient()
|
|
|
+ self.RefreshLine(self.layer_selected)
|
|
|
+
|
|
|
def OnSetBgMap(self, event):
|
|
|
"""!Set background vector map for editing sesstion"""
|
|
|
if event.IsChecked():
|
|
|
mapName = self.GetPyData(self.layer_selected)[0]['maplayer'].GetName()
|
|
|
- UserSettings.Set(group='vdigit', key='bgmap', subkey='value',
|
|
|
- value=str(mapName), internal=True)
|
|
|
+ UserSettings.Set(group = 'vdigit', key = 'bgmap', subkey = 'value',
|
|
|
+ value = str(mapName), internal = True)
|
|
|
+ self.mapdisplay.digit.OpenBackgroundMap(mapName)
|
|
|
+ self._setGradient('bgmap')
|
|
|
else:
|
|
|
- UserSettings.Set(group='vdigit', key='bgmap', subkey='value',
|
|
|
- value='', internal=True)
|
|
|
+ UserSettings.Set(group = 'vdigit', key = 'bgmap', subkey = 'value',
|
|
|
+ value = '', internal = True)
|
|
|
+ self.mapdisplay.digit.CloseBackgroundMap()
|
|
|
+ self._setGradient()
|
|
|
|
|
|
+ self.RefreshLine(self.layer_selected)
|
|
|
+
|
|
|
def OnPopupProperties (self, event):
|
|
|
"""!Popup properties dialog"""
|
|
|
self.PropertiesDialog(self.layer_selected)
|
|
@@ -593,8 +618,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
|
|
|
current_opacity = maplayer.GetOpacity()
|
|
|
|
|
|
- dlg = gdialogs.SetOpacityDialog(self, opacity=current_opacity,
|
|
|
- title=_("Set opacity <%s>") % maplayer.GetName())
|
|
|
+ dlg = gdialogs.SetOpacityDialog(self, opacity = current_opacity,
|
|
|
+ title = _("Set opacity <%s>") % maplayer.GetName())
|
|
|
dlg.CentreOnParent()
|
|
|
|
|
|
if dlg.ShowModal() == wx.ID_OK:
|
|
@@ -641,8 +666,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
event.Skip()
|
|
|
|
|
|
- def AddLayer(self, ltype, lname=None, lchecked=None,
|
|
|
- lopacity=1.0, lcmd=None, lgroup=None, lvdigit=None, lnviz=None, multiple = True):
|
|
|
+ def AddLayer(self, ltype, lname = None, lchecked = None,
|
|
|
+ lopacity = 1.0, lcmd = None, lgroup = None, lvdigit = None, lnviz = None, multiple = True):
|
|
|
"""!Add new item to the layer tree, create corresponding MapLayer instance.
|
|
|
Launch property dialog if needed (raster, vector, etc.)
|
|
|
|
|
@@ -671,16 +696,16 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
# deselect active item
|
|
|
if self.layer_selected:
|
|
|
- self.SelectItem(self.layer_selected, select=False)
|
|
|
+ self.SelectItem(self.layer_selected, select = False)
|
|
|
|
|
|
Debug.msg (3, "LayerTree().AddLayer(): ltype=%s" % (ltype))
|
|
|
|
|
|
if ltype == 'command':
|
|
|
# generic command item
|
|
|
- ctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
|
|
|
- pos=wx.DefaultPosition, size=(self.GetSize()[0]-100,25),
|
|
|
- # style=wx.TE_MULTILINE|wx.TE_WORDWRAP)
|
|
|
- style=wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)
|
|
|
+ ctrl = wx.TextCtrl(self, id = wx.ID_ANY, value = '',
|
|
|
+ pos = wx.DefaultPosition, size = (self.GetSize()[0]-100,25),
|
|
|
+ # style = wx.TE_MULTILINE|wx.TE_WORDWRAP)
|
|
|
+ style = wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP)
|
|
|
ctrl.Bind(wx.EVT_TEXT_ENTER, self.OnCmdChanged)
|
|
|
# ctrl.Bind(wx.EVT_TEXT, self.OnCmdChanged)
|
|
|
elif ltype == 'group':
|
|
@@ -690,7 +715,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
self.groupnode += 1
|
|
|
else:
|
|
|
btnbmp = Icons["layeropts"].GetBitmap((16,16))
|
|
|
- ctrl = buttons.GenBitmapButton(self, id=wx.ID_ANY, bitmap=btnbmp, size=(24,24))
|
|
|
+ ctrl = buttons.GenBitmapButton(self, id = wx.ID_ANY, bitmap = btnbmp, size = (24,24))
|
|
|
ctrl.SetToolTipString(_("Click to edit layer settings"))
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenu, ctrl)
|
|
|
# add layer to the layer tree
|
|
@@ -698,29 +723,29 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
if self.GetPyData(self.layer_selected)[0]['type'] == 'group' \
|
|
|
and self.IsExpanded(self.layer_selected):
|
|
|
# add to group (first child of self.layer_selected) if group expanded
|
|
|
- layer = self.PrependItem(parent=self.layer_selected,
|
|
|
- text='', ct_type=1, wnd=ctrl)
|
|
|
+ layer = self.PrependItem(parent = self.layer_selected,
|
|
|
+ text = '', ct_type = 1, wnd = ctrl)
|
|
|
else:
|
|
|
# prepend to individual layer or non-expanded group
|
|
|
if lgroup == -1:
|
|
|
# -> last child of root (loading from workspace)
|
|
|
- layer = self.AppendItem(parentId=self.root,
|
|
|
- text='', ct_type=1, wnd=ctrl)
|
|
|
+ layer = self.AppendItem(parentId = self.root,
|
|
|
+ text = '', ct_type = 1, wnd = ctrl)
|
|
|
elif lgroup > -1:
|
|
|
# -> last child of group (loading from workspace)
|
|
|
parent = self.FindItemByIndex(index = lgroup)
|
|
|
if not parent:
|
|
|
parent = self.root
|
|
|
- layer = self.AppendItem(parentId=parent,
|
|
|
- text='', ct_type=1, wnd=ctrl)
|
|
|
+ layer = self.AppendItem(parentId = parent,
|
|
|
+ text = '', ct_type = 1, wnd = ctrl)
|
|
|
elif lgroup is None:
|
|
|
# -> previous sibling of selected layer
|
|
|
parent = self.GetItemParent(self.layer_selected)
|
|
|
- layer = self.InsertItem(parentId=parent,
|
|
|
- input=self.GetPrevSibling(self.layer_selected),
|
|
|
- text='', ct_type=1, wnd=ctrl)
|
|
|
+ layer = self.InsertItem(parentId = parent,
|
|
|
+ input = self.GetPrevSibling(self.layer_selected),
|
|
|
+ text = '', ct_type = 1, wnd = ctrl)
|
|
|
else: # add first layer to the layer tree (first child of root)
|
|
|
- layer = self.PrependItem(parent=self.root, text='', ct_type=1, wnd=ctrl)
|
|
|
+ layer = self.PrependItem(parent = self.root, text = '', ct_type = 1, wnd = ctrl)
|
|
|
|
|
|
# layer is initially unchecked as inactive (beside 'command')
|
|
|
# use predefined value if given
|
|
@@ -729,10 +754,10 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
else:
|
|
|
checked = True
|
|
|
|
|
|
- self.CheckItem(layer, checked=checked)
|
|
|
+ self.CheckItem(layer, checked = checked)
|
|
|
|
|
|
# select new item
|
|
|
- self.SelectItem(layer, select=True)
|
|
|
+ self.SelectItem(layer, select = True)
|
|
|
self.layer_selected = layer
|
|
|
|
|
|
# add text and icons for each layer ltype
|
|
@@ -831,15 +856,15 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
else:
|
|
|
pos = -1
|
|
|
|
|
|
- maplayer = self.Map.AddLayer(pos=pos,
|
|
|
- type=ltype, command=self.GetPyData(layer)[0]['cmd'], name=name,
|
|
|
- l_active=checked, l_hidden=False,
|
|
|
- l_opacity=lopacity, l_render=render)
|
|
|
+ maplayer = self.Map.AddLayer(pos = pos,
|
|
|
+ type = ltype, command = self.GetPyData(layer)[0]['cmd'], name = name,
|
|
|
+ l_active = checked, l_hidden = False,
|
|
|
+ l_opacity = lopacity, l_render = render)
|
|
|
self.GetPyData(layer)[0]['maplayer'] = maplayer
|
|
|
|
|
|
# run properties dialog if no properties given
|
|
|
if len(cmd) == 0:
|
|
|
- self.PropertiesDialog(layer, show=True)
|
|
|
+ self.PropertiesDialog(layer, show = True)
|
|
|
|
|
|
else: # group
|
|
|
self.SetPyData(layer, ({'cmd' : None,
|
|
@@ -861,11 +886,11 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
# updated progress bar range (mapwindow statusbar)
|
|
|
if checked is True:
|
|
|
- self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active=True)))
|
|
|
+ self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active = True)))
|
|
|
|
|
|
return layer
|
|
|
|
|
|
- def PropertiesDialog (self, layer, show=True):
|
|
|
+ def PropertiesDialog (self, layer, show = True):
|
|
|
"""!Launch the properties dialog"""
|
|
|
if self.GetPyData(layer)[0].has_key('propwin') and \
|
|
|
self.GetPyData(layer)[0]['propwin'] is not None:
|
|
@@ -890,68 +915,68 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
if self.GetPyData(layer)[0]['cmd']:
|
|
|
module = menuform.GUI()
|
|
|
module.ParseCommand(self.GetPyData(layer)[0]['cmd'],
|
|
|
- completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, show=show, centreOnParent = False)
|
|
|
+ completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, show = show, centreOnParent = False)
|
|
|
|
|
|
self.GetPyData(layer)[0]['cmd'] = module.GetCmd()
|
|
|
elif ltype == 'raster':
|
|
|
cmd = ['d.rast']
|
|
|
|
|
|
- if UserSettings.Get(group='cmd', key='rasterOpaque', subkey='enabled'):
|
|
|
+ if UserSettings.Get(group = 'cmd', key = 'rasterOpaque', subkey = 'enabled'):
|
|
|
cmd.append('-n')
|
|
|
- menuform.GUI().ParseCommand(cmd, completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(cmd, completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == '3d-raster':
|
|
|
cmd = ['d.rast3d']
|
|
|
- menuform.GUI().ParseCommand(cmd, completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(cmd, completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'rgb':
|
|
|
- menuform.GUI().ParseCommand(['d.rgb'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.rgb'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'his':
|
|
|
- menuform.GUI().ParseCommand(['d.his'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.his'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'shaded':
|
|
|
- menuform.GUI().ParseCommand(['d.shadedmap'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.shadedmap'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'rastarrow':
|
|
|
- menuform.GUI().ParseCommand(['d.rast.arrow'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.rast.arrow'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'rastnum':
|
|
|
- menuform.GUI().ParseCommand(['d.rast.num'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.rast.num'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'vector':
|
|
|
types = ''
|
|
|
- for type in UserSettings.Get(group='cmd', key='showType').keys():
|
|
|
- if UserSettings.Get(group='cmd', key='showType', subkey=[type, 'enabled']):
|
|
|
+ for type in UserSettings.Get(group = 'cmd', key = 'showType').keys():
|
|
|
+ if UserSettings.Get(group = 'cmd', key = 'showType', subkey = [type, 'enabled']):
|
|
|
types += type + ','
|
|
|
types = types.rstrip(',')
|
|
|
|
|
|
menuform.GUI().ParseCommand(['d.vect', 'type=%s' % types],
|
|
|
- completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'thememap':
|
|
|
# -s flag requested, otherwise only first thematic category is displayed
|
|
|
# should be fixed by C-based d.thematic.* modules
|
|
|
menuform.GUI().ParseCommand(['d.thematic.area'],
|
|
|
- completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'themechart':
|
|
|
menuform.GUI().ParseCommand(['d.vect.chart'],
|
|
|
- completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'grid':
|
|
|
- menuform.GUI().ParseCommand(['d.grid'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.grid'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'geodesic':
|
|
|
- menuform.GUI().ParseCommand(['d.geodesic'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.geodesic'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'rhumb':
|
|
|
- menuform.GUI().ParseCommand(['d.rhumbline'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.rhumbline'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'labels':
|
|
|
- menuform.GUI().ParseCommand(['d.labels'], completed=(self.GetOptData,layer,params),
|
|
|
- parentframe=self, centreOnParent = False)
|
|
|
+ menuform.GUI().ParseCommand(['d.labels'], completed = (self.GetOptData,layer,params),
|
|
|
+ parentframe = self, centreOnParent = False)
|
|
|
elif ltype == 'cmdlayer':
|
|
|
pass
|
|
|
elif ltype == 'group':
|
|
@@ -1004,10 +1029,10 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
self.reorder = True
|
|
|
|
|
|
if self.mapdisplay.toolbars['vdigit']:
|
|
|
- self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers (updateTool=True)
|
|
|
+ self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers (updateTool = True)
|
|
|
|
|
|
# update progress bar range (mapwindow statusbar)
|
|
|
- self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active=True)))
|
|
|
+ self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active = True)))
|
|
|
|
|
|
event.Skip()
|
|
|
|
|
@@ -1041,7 +1066,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
#
|
|
|
# update progress bar range (mapwindow statusbar)
|
|
|
#
|
|
|
- self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active=True)))
|
|
|
+ self.mapdisplay.statusbarWin['progress'].SetRange(len(self.Map.GetListOfLayers(l_active = True)))
|
|
|
|
|
|
#
|
|
|
# nviz
|
|
@@ -1103,6 +1128,17 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
event.Veto()
|
|
|
return
|
|
|
|
|
|
+ digitToolbar = self.mapdisplay.toolbars['vdigit']
|
|
|
+ mapLayer = self.GetPyData(layer)[0]['maplayer']
|
|
|
+ bgmap = UserSettings.Get(group = 'vdigit', key = 'bgmap', subkey = 'value',
|
|
|
+ internal = True)
|
|
|
+ if digitToolbar and digitToolbar.GetLayer() == mapLayer:
|
|
|
+ self._setGradient('vdigit')
|
|
|
+ elif bgmap == mapLayer.GetName():
|
|
|
+ self._setGradient('bgmap')
|
|
|
+ else:
|
|
|
+ self._setGradient()
|
|
|
+
|
|
|
self.layer_selected = layer
|
|
|
|
|
|
try:
|
|
@@ -1117,21 +1153,21 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
self.SetItemWindowEnabled(layer, False)
|
|
|
except:
|
|
|
pass
|
|
|
-
|
|
|
+
|
|
|
try:
|
|
|
self.RefreshLine(oldlayer)
|
|
|
self.RefreshLine(layer)
|
|
|
except:
|
|
|
pass
|
|
|
-
|
|
|
+
|
|
|
#
|
|
|
# update statusbar -> show command string
|
|
|
#
|
|
|
if self.GetPyData(layer) and self.GetPyData(layer)[0]['maplayer']:
|
|
|
- cmd = self.GetPyData(layer)[0]['maplayer'].GetCmd(string=True)
|
|
|
+ cmd = self.GetPyData(layer)[0]['maplayer'].GetCmd(string = True)
|
|
|
if len(cmd) > 0:
|
|
|
self.lmgr.SetStatusText(cmd)
|
|
|
-
|
|
|
+
|
|
|
# set region if auto-zooming is enabled
|
|
|
if self.GetPyData(layer) and self.GetPyData(layer)[0]['cmd'] and \
|
|
|
UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'):
|
|
@@ -1203,7 +1239,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
(child, cookie) = self.GetFirstChild(dragItem)
|
|
|
if child:
|
|
|
while child:
|
|
|
- self.RecreateItem(child, dropTarget, parent=newItem)
|
|
|
+ self.RecreateItem(child, dropTarget, parent = newItem)
|
|
|
self.Delete(child)
|
|
|
child = self.GetNextChild(old, cookie)[0]
|
|
|
#self.Expand(newItem)
|
|
@@ -1225,7 +1261,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
# select new item
|
|
|
self.SelectItem(newItem)
|
|
|
|
|
|
- def RecreateItem (self, dragItem, dropTarget, parent=None):
|
|
|
+ def RecreateItem (self, dragItem, dropTarget, parent = None):
|
|
|
"""!Recreate item (needed for OnEndDrag())
|
|
|
"""
|
|
|
Debug.msg (4, "LayerTree.RecreateItem(): layer=%s" % \
|
|
@@ -1238,7 +1274,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
if self.GetPyData(dragItem)[0]['ctrl']:
|
|
|
# recreate data layer
|
|
|
btnbmp = Icons["layeropts"].GetBitmap((16,16))
|
|
|
- newctrl = buttons.GenBitmapButton(self, id=wx.ID_ANY, bitmap=btnbmp, size=(24, 24))
|
|
|
+ newctrl = buttons.GenBitmapButton(self, id = wx.ID_ANY, bitmap = btnbmp, size = (24, 24))
|
|
|
newctrl.SetToolTipString(_("Click to edit layer settings"))
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenu, newctrl)
|
|
|
data = self.GetPyData(dragItem)
|
|
@@ -1246,11 +1282,11 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
elif self.GetPyData(dragItem)[0]['type'] == 'command':
|
|
|
# recreate command layer
|
|
|
oldctrl = None
|
|
|
- newctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
|
|
|
- pos=wx.DefaultPosition, size=(250,25),
|
|
|
- style=wx.TE_MULTILINE|wx.TE_WORDWRAP)
|
|
|
+ newctrl = wx.TextCtrl(self, id = wx.ID_ANY, value = '',
|
|
|
+ pos = wx.DefaultPosition, size = (250,25),
|
|
|
+ style = wx.TE_MULTILINE|wx.TE_WORDWRAP)
|
|
|
try:
|
|
|
- newctrl.SetValue(self.GetPyData(dragItem)[0]['maplayer'].GetCmd(string=True))
|
|
|
+ newctrl.SetValue(self.GetPyData(dragItem)[0]['maplayer'].GetCmd(string = True))
|
|
|
except:
|
|
|
pass
|
|
|
newctrl.Bind(wx.EVT_TEXT_ENTER, self.OnCmdChanged)
|
|
@@ -1273,27 +1309,27 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
# dragItem dropped on group
|
|
|
if self.GetPyData(afteritem)[0]['type'] == 'group':
|
|
|
- newItem = self.PrependItem(afteritem, text=text, \
|
|
|
- ct_type=1, wnd=newctrl, image=image, \
|
|
|
- data=data)
|
|
|
+ newItem = self.PrependItem(afteritem, text = text, \
|
|
|
+ ct_type = 1, wnd = newctrl, image = image, \
|
|
|
+ data = data)
|
|
|
self.Expand(afteritem)
|
|
|
else:
|
|
|
#dragItem dropped on single layer
|
|
|
newparent = self.GetItemParent(afteritem)
|
|
|
newItem = self.InsertItem(newparent, self.GetPrevSibling(afteritem), \
|
|
|
- text=text, ct_type=1, wnd=newctrl, \
|
|
|
- image=image, data=data)
|
|
|
+ text = text, ct_type = 1, wnd = newctrl, \
|
|
|
+ image = image, data = data)
|
|
|
else:
|
|
|
# if dragItem not dropped on a layer or group, append or prepend it to the layer tree
|
|
|
if self.flag & wx.TREE_HITTEST_ABOVE:
|
|
|
- newItem = self.PrependItem(self.root, text=text, \
|
|
|
- ct_type=1, wnd=newctrl, image=image, \
|
|
|
- data=data)
|
|
|
+ newItem = self.PrependItem(self.root, text = text, \
|
|
|
+ ct_type = 1, wnd = newctrl, image = image, \
|
|
|
+ data = data)
|
|
|
elif (self.flag & wx.TREE_HITTEST_BELOW) or (self.flag & wx.TREE_HITTEST_NOWHERE) \
|
|
|
or (self.flag & wx.TREE_HITTEST_TOLEFT) or (self.flag & wx.TREE_HITTEST_TORIGHT):
|
|
|
- newItem = self.AppendItem(self.root, text=text, \
|
|
|
- ct_type=1, wnd=newctrl, image=image, \
|
|
|
- data=data)
|
|
|
+ newItem = self.AppendItem(self.root, text = text, \
|
|
|
+ ct_type = 1, wnd = newctrl, image = image, \
|
|
|
+ data = data)
|
|
|
|
|
|
#update new layer
|
|
|
self.SetPyData(newItem, self.GetPyData(dragItem))
|
|
@@ -1302,7 +1338,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
else:
|
|
|
self.GetPyData(newItem)[0]['ctrl'] = None
|
|
|
|
|
|
- self.CheckItem(newItem, checked=checked) # causes a new render
|
|
|
+ self.CheckItem(newItem, checked = checked) # causes a new render
|
|
|
|
|
|
# newItem.SetHeight(TREE_ITEM_HEIGHT)
|
|
|
|
|
@@ -1386,8 +1422,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
mapWin.LoadVector(layer)
|
|
|
|
|
|
# reset view when first layer loaded
|
|
|
- nlayers = len(mapWin.Map.GetListOfLayers(l_type=('raster', 'vector'),
|
|
|
- l_active=True))
|
|
|
+ nlayers = len(mapWin.Map.GetListOfLayers(l_type = ('raster', 'vector'),
|
|
|
+ l_active = True))
|
|
|
if nlayers < 2:
|
|
|
mapWin.ResetView()
|
|
|
|
|
@@ -1442,23 +1478,23 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
elif type != 'group':
|
|
|
if self.GetPyData(item)[0] is not None:
|
|
|
cmdlist = self.GetPyData(item)[0]['cmd']
|
|
|
- opac = self.GetPyData(item)[0]['maplayer'].GetOpacity(float=True)
|
|
|
+ opac = self.GetPyData(item)[0]['maplayer'].GetOpacity(float = True)
|
|
|
chk = self.IsItemChecked(item)
|
|
|
hidden = not self.IsVisible(item)
|
|
|
# determine layer name
|
|
|
- layerName = utils.GetLayerNameFromCmd(cmdlist, fullyQualified=True)
|
|
|
+ layerName = utils.GetLayerNameFromCmd(cmdlist, fullyQualified = True)
|
|
|
if not layerName:
|
|
|
layerName = self.GetItemText(item)
|
|
|
|
|
|
- maplayer = self.Map.ChangeLayer(layer=self.GetPyData(item)[0]['maplayer'], type=type,
|
|
|
- command=cmdlist, name=layerName,
|
|
|
- l_active=chk, l_hidden=hidden, l_opacity=opac, l_render=False)
|
|
|
+ maplayer = self.Map.ChangeLayer(layer = self.GetPyData(item)[0]['maplayer'], type = type,
|
|
|
+ command = cmdlist, name = layerName,
|
|
|
+ l_active = chk, l_hidden = hidden, l_opacity = opac, l_render = False)
|
|
|
|
|
|
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)
|
|
|
+ self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers(updateTool = True)
|
|
|
|
|
|
# redraw map if auto-rendering is enabled
|
|
|
self.rerender = True
|
|
@@ -1494,7 +1530,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
|
|
|
|
|
|
return None
|
|
|
|
|
|
- def EnableItemType(self, type, enable=True):
|
|
|
+ def EnableItemType(self, type, enable = True):
|
|
|
"""!Enable/disable items in layer tree"""
|
|
|
item = self.GetFirstChild(self.root)[0]
|
|
|
while item and item.IsOk():
|