[GRASS-SVN] r42015 - grass-addons/gui/wxpython/data_catalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Apr 24 07:19:54 EDT 2010
Author: rashadkm
Date: 2010-04-24 07:19:54 -0400 (Sat, 24 Apr 2010)
New Revision: 42015
Modified:
grass-addons/gui/wxpython/data_catalog/LayerTree.py
grass-addons/gui/wxpython/data_catalog/mapdisplay.py
Log:
added layer select and deselect
Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-24 11:15:11 UTC (rev 42014)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-24 11:19:54 UTC (rev 42015)
@@ -1,22 +1,3 @@
-"""
- at package LayerTree.py
-
-
-
- at breif A LayerTree for managing maps
-based on selected location and mapset
-
-Classes:
- - LayerTree
-
-(C) 2007 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.
-
- at author Mohammed Rashad K.M <rashadkm at gmail dot com>
-
-"""
import os
import sys
import wx
@@ -119,11 +100,9 @@
item = event.GetItem()
checked = item.IsChecked()
+
-
pText = self.GetItemText(self.GetItemParent(item))
-
-
leftpanel=self.GetParent()
notebook = leftpanel.GetParent()
frame = notebook.GetParent()
@@ -136,37 +115,32 @@
#maptree = mapframe.maptree
if pText == "Raster Map" :
- self.cmd= ['d.rast', str("map=" + self.mapname)]
- l_type='raster'
-
- self.maplayer = self.MapWindow.Map.AddLayer(type='raster', name=self.mapname, command=self.cmd)
-
-
- #layer = maptree.PrependItem(parent=maptree.root, text=self.mapname, ct_type=1)
- #maptree.first = True
- #maptree.layer_selected = layer
- #maptree.CheckItem(layer)
- #self.layer.append(self.maplayer)
- #maptree.PlusLayer(self.maplayer)
-
-
+ if checked == True:
+ self.cmd= ['d.rast', str("map=" + self.mapname)]
+ self.MapWindow.Map.AddLayer(type='raster', name=self.mapname, command=self.cmd)
+ else:
+ layers = self.MapWindow.Map.GetListOfLayers( l_type='raster', l_name=self.mapname)
+ for layer in layers:
+ self.MapWindow.Map.DeleteLayer(layer)
+ self.MapWindow.EraseMap()
+
+
+
+
if pText == "Vector Map" :
- self.cmd= ['d.vect', str("map=" + self.mapname)]
- l_type='vector'
-
- self.maplayer = self.MapWindow.Map.AddLayer(type='vector', name=self.mapname, command=self.cmd)
-
-
+ if checked == True:
+ self.cmd= ['d.vect', str("map=" + self.mapname)]
+ self.MapWindow.Map.AddLayer(type='vector', name=self.mapname, command=self.cmd)
+ else:
+ layers = self.MapWindow.Map.GetListOfLayers( l_type='vector', l_name=self.mapname)
+ for layer in layers:
+ self.MapWindow.Map.DeleteLayer(layer)
+ self.MapWindow.EraseMap()
+
self.MapWindow.Map.region = self.MapWindow.Map.GetRegion()
self.MapWindow.flag = True
self.MapWindow.UpdateMap(render=True)
self.MapWindow.flag = False
- #layer = maptree.PrependItem(parent=maptree.root, text=self.mapname, ct_type=1)
- #maptree.first = True
- #maptree.layer_selected = layer
- #maptree.CheckItem(layer)
- #self.layer.append(self.maplayer)
- #maptree.PlusLayer(self.maplayer)
@@ -189,10 +163,12 @@
if not os.path.isfile(gloc) and os.path.isdir(gloc):
if(os.path.basename(gloc)=='cellhd'):
for rast in glob.glob(os.path.join(self.gisdbase,location, mapset,gloc, "*")):
- self.PrependItem(node_raster, os.path.basename(rast),ct_type=1)
+ rlayer = self.PrependItem(node_raster, os.path.basename(rast),ct_type=1)
+
elif(os.path.basename(gloc)=='vector'):
for vect in glob.glob(os.path.join(self.gisdbase,location, mapset,gloc, "*")):
- self.PrependItem(node_vector, os.path.basename(vect),ct_type=1)
+ vlayer=self.PrependItem(node_vector, os.path.basename(vect),ct_type=1)
+
elif(os.path.basename(gloc)=='dbf'):
for dfile in glob.glob(os.path.join(self.gisdbase,location, mapset,gloc, "*")):
self.PrependItem(node_dbf, os.path.basename(dfile),ct_type=1)
Modified: grass-addons/gui/wxpython/data_catalog/mapdisplay.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-04-24 11:15:11 UTC (rev 42014)
+++ grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-04-24 11:19:54 UTC (rev 42015)
@@ -5,12 +5,14 @@
management functions, and additional toolbars (vector digitizer, 3d
view).
+Can be used either from Layer Manager or as p.mon backend.
+
Classes:
-- Command
-- MapWindow
-- BufferedWindow
- MapFrame
+- MapApp
+Usage:
+python mapdisp.py monitor-identifier /path/to/command/file
(C) 2006-2009 by the GRASS Development Team
This program is free software under the GNU General Public
@@ -692,6 +694,7 @@
@param renderVector re-render vector map layer enabled for editing (used for digitizer)
"""
if self.flag == True:
+ self.flag = False
start = time.clock()
@@ -926,7 +929,6 @@
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)
@@ -2851,7 +2853,7 @@
self._mgr.AddPane(self.maptree, wx.aui.AuiPaneInfo().Left().
Dockable(False).BestSize((400,300)).
CloseButton(False).DestroyOnClose(True).
- Layer(0).Caption("MapTree"))
+ Layer(0).Caption("Map Tree"))
self._mgr.Update()
@@ -3309,8 +3311,10 @@
"""
Erase the canvas
"""
+
self.MapWindow.EraseMap()
+
def OnZoomRegion(self, event):
"""
Zoom to region
@@ -4570,4 +4574,47 @@
# end of class MapFrame
+class MapApp(wx.App):
+ """
+ MapApp class
+ """
+ def OnInit(self):
+
+ wx.InitAllImageHandlers()
+ if __name__ == "__main__":
+ Map = render.Map() # instance of Map class to render GRASS display output to PPM file
+ else:
+ Map = None
+
+ self.mapFrm = MapFrame(parent=None, id=wx.ID_ANY, Map=Map,
+ size=globalvar.MAP_WINDOW_SIZE)
+ #self.SetTopWindow(Map)
+ self.mapFrm.Show()
+
+ if __name__ == "__main__":
+ # redraw map, if new command appears
+ self.redraw = False
+
+
+ return 1
+
+
+# end of class MapApp
+
+if __name__ == "__main__":
+
+ ###### SET command variable
+
+
+ title = "title"
+ cmdfilename = "cmdfilename"
+
+
+
+ gm_map = MapApp(0)
+ # set title
+ gm_map.mapFrm.SetTitle(_("GRASS GIS Map Display: " + title + " - Location: " + grass.gisenv()["LOCATION_NAME"]))
+
+ gm_map.MainLoop()
+ sys.exit(0)
More information about the grass-commit
mailing list