[GRASS-SVN] r41935 - grass-addons/gui/wxpython/data_catalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Apr 20 12:53:12 EDT 2010
Author: rashadkm
Date: 2010-04-20 12:53:11 -0400 (Tue, 20 Apr 2010)
New Revision: 41935
Modified:
grass-addons/gui/wxpython/data_catalog/LayerTree.py
grass-addons/gui/wxpython/data_catalog/catalog.py
grass-addons/gui/wxpython/data_catalog/mapframe.py
grass-addons/gui/wxpython/data_catalog/wx_utils.py
Log:
fixed display for different mapsets
Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-20 15:34:05 UTC (rev 41934)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-20 16:53:11 UTC (rev 41935)
@@ -32,8 +32,8 @@
self.gisdbase = gisdbase
self.Map = None
- if self.Map is not None:
- print self.Map.width
+ #if self.Map is not None:
+ # print self.Map.width
self.ID_REN= wx.NewId()
self.ID_COPY = wx.NewId()
@@ -48,9 +48,11 @@
self.SetAcceleratorTable(acel)
+ self.dict = {}
+
def AddTreeNodes(self,location,mapset):
"""
Adds tree nodes. raster,vector and dbf files are identified using
@@ -267,6 +269,7 @@
item = event.GetItem()
pText = self.GetItemText(self.GetItemParent(item))
+
leftpanel=self.GetParent()
splitter = leftpanel.GetParent()
@@ -279,11 +282,16 @@
#win.SetSelection(0)
child=win.GetChildren()
for panel in child:
+ #print panel.GetName()
if panel.GetName() == "pg_panel":
mapframe = panel
+
+
# mtree = mapframe.maptree
#print mtree.GetName()
+
+
if not self.ItemHasChildren(item):
@@ -293,8 +301,33 @@
if pText == "Raster Map" :
self.cmd= ['d.rast', str("map=" + self.mapname)]
+ l_type="raster"
+
+ #mapframe.Map.AddLayer(type=l_type, name=self.mapname, command=self.cmd)
+
mapframe.maptree.AddLayer(ltype="raster", lname=self.mapname, lchecked=True,lcmd=self.cmd)
- l_type="raster"
+
+
+ mapframe.Map.region = mapframe.Map.GetRegion()
+# mapframe.MapWindow2D.flag = True
+# mapframe.MapWindow2D.UpdateMap(render=True)
+
+
+
+
+ #update new layer
+# mapframe.maptree.SetPyData(newItem, mapframe.maptree.GetPyData(dragItem))
+
+
+# mapframe.maptree.CheckItem(newItem, checked=True) # causes a new render
+# mapframe.maptree.SelectItem(newItem, select=True)
+
+
+
+
+
+
+
#self.infocmd = ["r.info", str(self.mapname)]
elif pText == "Vector Map" :
self.cmd= ['d.vect', str("map=" + self.mapname)]
Modified: grass-addons/gui/wxpython/data_catalog/catalog.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/catalog.py 2010-04-20 15:34:05 UTC (rev 41934)
+++ grass-addons/gui/wxpython/data_catalog/catalog.py 2010-04-20 16:53:11 UTC (rev 41935)
@@ -97,15 +97,14 @@
from LayerTree import LayerTree
import wx.lib.flatnotebook as FN
from icons.icon import Icons
-import wx_utils as wx_utils
from preferences import globalSettings as UserSettings
import render
+import gc
-
class DataCatalog(wx.Frame):
- def __init__(self, parent=None, id=wx.ID_ANY, title=_("Data Catalog"),
+ def __init__(self, parent=None, id=wx.ID_ANY, title=_("Data Catalog Beta"),
workspace=None,size=wx.DefaultSize,pos=wx.DefaultPosition):
@@ -117,7 +116,9 @@
#self.Maximize()
+ self.dict = {}
+
self.gisbase = os.getenv("GISBASE")
self.gisrc = self.read_gisrc()
self.viewInfo = True #to display v/r.info on mapdisplay
@@ -147,6 +148,9 @@
self.locationchange = True
self.menucmd = dict()
+
+
+
#creating sizers
@@ -184,6 +188,7 @@
self.pg_panel = None
self.cb_loclist = []
self.cb_maplist = []
+ self.cb_mapfile = []
#creating controls
#self.mInfo = wx.TextCtrl(self.pRight, wx.ID_ANY, style = wx.TE_MULTILINE|wx.HSCROLL|wx.TE_READONLY)
@@ -205,7 +210,8 @@
# self._mgr.AddPane(self.cmdprompt, wx.aui.AuiPaneInfo().CentrePane().Dockable(False).BestSize((-1,-1)).CloseButton(False).DestroyOnClose(True). Layer(0))
- self.current = self.notebook.GetCurrentPage()
+ self.current = self.notebook.GetCurrentPage()
+
self.goutput = goutput.GMConsole(self, pageid=1)
self.goutput.Hide()
@@ -239,6 +245,7 @@
for self.subpanel in self.panel:
if self.subpanel.GetName() == "pg_panel":
self.newmap = self.subpanel.Map
+ break
return self.newmap
@@ -313,7 +320,7 @@
if version == "6.4.0svn":
self.__createMenuItem(menu, *eachItem)
else:
- self.__createMenuItem2(menu, *eachItem)
+ self.__createMenuItem7(menu, *eachItem)
self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight)
return menu
@@ -342,7 +349,7 @@
self.Bind(wx.EVT_MENU, rhandler, menuItem)
- def __createMenuItem2(self, menu, label, help, handler, gcmd, keywords, shortcut = '', kind = wx.ITEM_NORMAL):
+ def __createMenuItem7(self, menu, label, help, handler, gcmd, keywords, shortcut = '', kind = wx.ITEM_NORMAL):
"""!Creates menu items"""
if not label:
@@ -509,8 +516,8 @@
self.notebook.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx), select = True)
- self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnPageClosed)
+ # self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
+ # self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnPageClosed)
self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnCBPageChanged)
self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosed)
@@ -522,10 +529,6 @@
"""!Page in notebook changed"""
pageno = event.GetSelection()
self.page = self.notebook.GetPage(pageno)
- self.page.Map.__init__()
- self.page.Map.region = self.page.Map.GetRegion()
- p =event.GetParent()
- print "ss"
if page == self.goutput.pageid:
# remove '(...)'
self.notebook.SetPageText(page, _("Command output"))
@@ -567,6 +570,7 @@
self.notebook.GetPage(event.GetSelection()).maptree.Map.Clean()
self.notebook.GetPage(event.GetSelection()).maptree.Close(True)
+ self.disp_idx = self.disp_idx - 1
self.curr_page = None
@@ -574,23 +578,54 @@
def OnCBPageChanged(self, event):
"""!Page in notebook (display) changed"""
+
+
+ #import pdb
+ #pdb.set_trace()
+
+
old_pgnum = event.GetOldSelection()
new_pgnum = event.GetSelection()
+
+ self.oldpage = self.notebook.GetPage(old_pgnum)
+
+
+
+ # self.cb_mapfile.append(render.Map)
+
+
self.curr_page = self.notebook.GetCurrentPage()
self.curr_pagenum = self.notebook.GetSelection()
+
+
+
+
self.ltree.DeleteAllItems()
# self.cmbMapset.SetValue(self.cb_loclist[self.disp_idx])
# self.cmbLocation.SetValue(self.cb_loclist[self.disp_idx])
# self.disp_idx
+
+
+ index = self.notebook.GetSelection()
+ self.page = self.notebook.GetPage(index)
+
+
+
- index = self.notebook.GetSelection()
- print index
- #index = index - 1
+
+ # print index
+# print self.cb_mapfile
+ #import pdb
+ # pdb.set_trace()
+
try:
a_loc = str(self.cb_loclist[index])
a_map = str(self.cb_maplist[index])
+
+ # a_mapfile = self.cb_mapfile[index]
+
except IndexError:
a_loc = "Select Location"
a_map = "Select Mapset"
@@ -600,13 +635,64 @@
self.ltree.AddTreeNodes(a_loc,a_map)
+
try:
- self.curr_page.maptree.mapdisplay.SetFocus()
- self.curr_page.maptree.mapdisplay.Raise()
+ self.gisrc['LOCATION_NAME'] = self.cb_loclist[index]
+ self.gisrc['MAPSET'] = self.cb_maplist[index]
+ #self.page.Map = self.cb_mapfile[index]
+
except:
pass
+ #self.page.Map.Region = self.page.Map.GetRegion()
+
+ self.update_grassrc(self.gisrc)
+ # self.page.Map.GetWindow()
+ # self.page.Map.InitGisEnv()
+ for key, val in self.page.maptree.mapdict.iteritems():
+ self.mapname = key
+ if val == "raster":
+ l_type="raster"
+ self.cmd= ['d.rast', str("map=" + self.mapname)]
+ else:
+ l_type = "vector"
+ self.cmd= ['d.vect', str("map=" + self.mapname)]
+
+
+ # self.page.maptree.AddLayer(ltype=l_type, lname=self.mapname, lchecked=True,lcmd=self.cmd)
+ #item1 = self.page.maptree.FindItem(idParent=self.page.maptree.root,prefixOrig=self.mapname)
+
+
+ # print self.page.maptree.GetItemText(item1)
+ #self.page.maptree.Delete(item1)
+
+ #print self.page.maptree.mapdict
+
+
+ # self.page.MapWindow.UpdateMap(render=True)
+ #self.oldpage.Map.region = self.oldpage.Map.GetRegion()
+ #self.page.Map.region = self.page.Map.GetRegion()
+
+
+
+# print self.region
+# print self.page.Map.region
+# print self.cmbLocation.GetValue()
+ #self.gisrc['LOCATION_NAME'] = str(self.cmbLocation.GetValue())
+ #self.gisrc['MAPSET'] = str(self.cmbMapset.GetValue())
+ #self.update_grassrc(self.gisrc)
+
+ # self.curr_page.Map.__init__()
+ # self.curr_page.Map.region = self.curr_page.Map.GetRegion()
+
+
- event.Skip()
+ # try:
+ #self.curr_page.maptree.mapdisplay.SetFocus()
+ #self.curr_page.maptree.mapdisplay.Raise()
+ # except:
+ # pass
+
+ # event.Skip()
@@ -750,8 +836,6 @@
def OnNewVector(self, event):
"""!Create new vector map layer"""
- import pdb
- pdb.set_trace()
name, add = gdialogs.CreateNewVector(self, cmd = (('v.edit', { 'tool' : 'create' }, 'map')))
if name and add:
@@ -1377,6 +1461,11 @@
"""
Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
+ wx.MessageBox(parent=self,
+ message=_("This part is under development. New display does not work when you change location and mapset"),
+ caption=_("Data Catalog"),
+ style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+
# make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
self.disp_idx = self.disp_idx + 1
@@ -1723,8 +1812,55 @@
for layer in self.current.maptree.GetSelections():
if self.current.maptree.GetPyData(layer)[0]['type'] == 'group':
self.current.maptree.DeleteChildren(layer)
- self.current.maptree.Delete(layer)
+ self.current.maptree.Delete(layer)
+
+
+
+ item = self.current.maptree.item
+ try:
+ self.current.maptree.item.properties.Close(True)
+ except:
+ pass
+
+ #if item != self.current.maptree.root:
+ # Debug.msg (3, "LayerTree.OnDeleteLayer(): name=%s" % \
+ # (self.current.maptree.GetItemText(item)))
+ # else:
+ # self.current.maptree.root = None
+
+ # unselect item
+ self.current.maptree.Unselect()
+ self.current.maptree.layer_selected = None
+
+ #try:
+ # if self.current.maptree.GetPyData(item)[0]['type'] != 'group':
+ nb = self.notebook.GetCurrentPage()
+ #print nb.maptree
+ index = self.notebook.GetSelection()
+ nb.Map.DeleteLayer( nb.maptree.layer[index])
+ nb.maptree.layer.remove(nb.maptree.layer[index])
+
+ #except:
+ # pass
+
+ # redraw map if auto-rendering is enabled
+ self.current.maptree.rerender = True
+ self.current.maptree.reorder = True
+ #if self.mapdisplay.statusbarWin['render'].GetValue():
+ # print "*** Delete OnRender *****"
+ # self.mapdisplay.OnRender(None)
+
+
+ # if self.mapdisplay.toolbars['vdigit']:
+ # 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.current.Map.UpdateMap(render=True)
+
+
def OnKey(self, event):
"""!Check hotkey"""
try:
@@ -1774,19 +1910,23 @@
self.gisrc['LOCATION_NAME'] = str(self.cmbLocation.GetValue())
self.gisrc['MAPSET'] = str(self.cmbMapset.GetValue())
self.update_grassrc(self.gisrc)
+
- #self.pg_panel.Map.__init__()
- #self.pg_panel.Map.region = self.pg_panel.Map.GetRegion()
-
self.page = self.notebook.GetPage(self.notebook.GetSelection())
self.page.Map.__init__()
self.page.Map.region = self.page.Map.GetRegion()
- if self.locationchange:
+ if self.locationchange == True:
self.cb_loclist.append( str(self.cmbLocation.GetValue()) )
self.cb_maplist.append( str(self.cmbMapset.GetValue()) )
- self.locationchange=False
- print self.cb_loclist
+
+ #self.cb_mapfile.append( self.page.Map)
+ self.locationchange = False
+
+
+
+
+
@@ -1972,6 +2112,9 @@
#gc.enable()
#gc.set_debug(gc.DEBUG_LEAK)
+ #print gc.garbage
+ #gc.collect()
+
g_catalog = CatalogApp(0)
g_catalog.MainLoop()
Modified: grass-addons/gui/wxpython/data_catalog/mapframe.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/mapframe.py 2010-04-20 15:34:05 UTC (rev 41934)
+++ grass-addons/gui/wxpython/data_catalog/mapframe.py 2010-04-20 16:53:11 UTC (rev 41935)
@@ -347,6 +347,7 @@
"""
Draws map and overlay decorations
"""
+
if drawid == None:
if pdctype == 'image' and img:
drawid = self.imagedict[img]
@@ -693,6 +694,7 @@
start = time.clock()
+
self.resize = False
# if len(self.Map.GetListOfLayers()) == 0:
@@ -2592,6 +2594,8 @@
self.layerbook = notebook # GIS Manager layer tree notebook
self.parent = parent
+ self.layers = {}
+
#
# available cursors
#
Modified: grass-addons/gui/wxpython/data_catalog/wx_utils.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/wx_utils.py 2010-04-20 15:34:05 UTC (rev 41934)
+++ grass-addons/gui/wxpython/data_catalog/wx_utils.py 2010-04-20 16:53:11 UTC (rev 41935)
@@ -87,7 +87,12 @@
self.EnableSelectionGradient(True)
self.SetFirstGradientColour(wx.Colour(100, 100, 100))
self.SetSecondGradientColour(wx.Colour(150, 150, 150))
+
+ self.mapdict = {}
+ self.item = None
+
+ self.layer = []
@@ -209,7 +214,7 @@
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivateLayer)
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnChangeSel)
self.Bind(CT.EVT_TREE_ITEM_CHECKED, self.OnLayerChecked)
- self.Bind(wx.EVT_TREE_DELETE_ITEM, self.OnDeleteLayer)
+ # self.Bind(wx.EVT_TREE_DELETE_ITEM, self.OnDeleteLayer)
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnLayerContextMenu)
#self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnDrag)
self.Bind(wx.EVT_TREE_END_DRAG, self.OnEndDrag)
@@ -287,6 +292,8 @@
q= p.GetParent()
r= q.GetParent()
frame= r.GetParent()
+ print "Ss"
+ print frame.GetName()
self.Bind(wx.EVT_MENU, frame.OnDeleteLayer, id=self.popupID1)
if ltype != "command": # rename
@@ -656,9 +663,9 @@
self.first = True
params = {} # no initial options parameters
- # import pdb
- # pdb.set_trace()
+ self.mapdict[str(lname)]=str(ltype)
+
# deselect active item
if self.layer_selected:
self.SelectItem(self.layer_selected, select=False)
@@ -826,6 +833,8 @@
l_opacity=lopacity, l_render=render)
self.GetPyData(layer)[0]['maplayer'] = maplayer
+ self.layer.append(maplayer)
+
# run properties dialog if no properties given
if len(cmd) == 0:
self.PropertiesDialog(layer, show=True)
@@ -970,13 +979,17 @@
def OnDeleteLayer(self, event):
"""!Remove selected layer item from the layer tree"""
- item = event.GetItem()
+ self.item = event.GetItem()
+ item = self.item
+ myString = self.GetItemText(item)
+ substr = myString[0:myString.find(" ")]
+ del self.mapdict[str(substr)]
+ #print self.mapname_list
try:
item.properties.Close(True)
except:
pass
-
if item != self.root:
Debug.msg (3, "LayerTree.OnDeleteLayer(): name=%s" % \
(self.GetItemText(item)))
More information about the grass-commit
mailing list