[GRASS-SVN] r42069 - grass-addons/gui/wxpython/data_catalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 1 04:57:42 EDT 2010
Author: rashadkm
Date: 2010-05-01 04:57:41 -0400 (Sat, 01 May 2010)
New Revision: 42069
Modified:
grass-addons/gui/wxpython/data_catalog/LayerTree.py
grass-addons/gui/wxpython/data_catalog/catalog.py
grass-addons/gui/wxpython/data_catalog/mapdisplay.py
Log:
fixed multiple location issues
Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-04-30 18:56:50 UTC (rev 42068)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-05-01 08:57:41 UTC (rev 42069)
@@ -55,12 +55,8 @@
self.ID_COPY = wx.NewId()
self.ID_DEL = wx.NewId()
self.ID_OSSIM = wx.NewId()
- self.ID_OSSIM2 = wx.NewId()
self.ID_INFO = wx.NewId()
self.ID_REPORT = wx.NewId()
- self.ID_AREA = 200
- self.ID_LENGTH = 201
- self.ID_COOR = 202
acel = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('R'), self.ID_REN ) ,
@@ -72,9 +68,6 @@
self.dict = {}
- self.colour = '0:0:0' #default colour for vector lines
- self.colour_selected = False
-
self.layer = []
self.maplayer = None
@@ -89,8 +82,8 @@
self.MapWindow = self.mapdisplay.MapWindow2D
self.Bind(CT.EVT_TREE_ITEM_CHECKED, self.OnLayerChecked)
- self.Bind(CT.EVT_TREE_ITEM_ACTIVATED, self.ChooseColour)
+
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK,self.OnTreePopUp)
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndRename)
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginRename)
@@ -100,41 +93,10 @@
self.Bind(wx.EVT_MENU,self.OnRename,id=self.ID_REN)
self.Bind(wx.EVT_MENU,self.OnDelete,id=self.ID_DEL)
self.Bind(wx.EVT_MENU,self.OnOssim,id=self.ID_OSSIM)
- self.Bind(wx.EVT_MENU,self.OnOssim2,id=self.ID_OSSIM2)
self.Bind(wx.EVT_MENU,self.OnInfo,id=self.ID_INFO)
self.Bind(wx.EVT_MENU,self.OnReport,id=self.ID_REPORT)
- self.Bind(wx.EVT_MENU,self.OnvReport,id=self.ID_AREA)
- self.Bind(wx.EVT_MENU,self.OnvReport,id=self.ID_LENGTH)
- self.Bind(wx.EVT_MENU,self.OnvReport,id=self.ID_COOR)
- def ChooseColour(self,event):
-
- colourdialog = wx.ColourDialog(self)
- colourdialog.ShowModal()
- rgb = colourdialog.GetColourData().GetColour()
- rgb = str(rgb)
- self.colour = rgb.replace(',',':')
- self.colour = self.colour.strip('(')
- self.colour = self.colour.strip(')')
-
- item = event.GetItem()
- col = colourdialog.GetColourData().GetColour()
-
- self.SetHilightFocusColour(col)
- self.SetItemTextColour(item,col)
- item = event.GetItem()
- parent = self.GetItemParent(item)
- if self.IsItemChecked(parent):
- self.colour_selected = True
- self.CheckItem(parent)
- else:
- self.CheckItem(parent)
-
-
-
-
-
def OnInfo(self,event):
item = self.GetSelection()
@@ -165,6 +127,7 @@
notebook = leftpanel.GetParent()
frame = notebook.GetParent()
+ notebook.SetSelection(2)
if not self.ItemHasChildren(item):
self.mapname = self.GetItemText(item) + "@" + frame.cmbMapset.GetValue()
@@ -172,38 +135,15 @@
if pText == "Raster Map" :
command = ["r.report", 'map=' + self.mapname]
frame.goutput.RunCmd(command)
-# if pText == "Vector Map" :
-# command = ["v.report", 'map=' + self.mapname]
-# frame.goutput.RunCmd(command)
+ if pText == "Vector Map" :
+ command = ["v.report", 'map=' + self.mapname]
+ frame.goutput.RunCmd(command)
- def OnvReport(self,event):
- item = self.GetSelection()
- Id = event.GetId()
- if Id == 200:
- option = 'area'
- elif Id == 201:
- option = 'length'
- elif Id == 202:
- option = 'coor'
- parent = self.GetItemParent(item)
- pText = self.GetItemText(parent)
- leftpanel=self.GetParent()
- notebook = leftpanel.GetParent()
- frame = notebook.GetParent()
-
- #if not self.ItemHasChildren(item):
- self.mapname = self.GetItemText(item) + "@" + frame.cmbMapset.GetValue()
- command = ["v.report", 'map=' + self.mapname,'option=' + str(option)]
- frame.goutput.RunCmd(command)
-
-
-
-
def OnLayerChecked(self, event):
"""!Enable/disable data layer"""
@@ -219,54 +159,44 @@
frame = notebook.GetParent()
+ if not self.ItemHasChildren(item):
+ self.mapname = self.GetItemText(item) + "@" + frame.cmbMapset.GetValue()
+ #for f in frames:
+ # print f.GetName()
+ #maptree = mapframe.maptree
-
-
- self.mapname = self.GetItemText(item) + "@" + frame.cmbMapset.GetValue()
- #for f in frames:
- # print f.GetName()
- #maptree = mapframe.maptree
-
- if pText == "Raster Map" :
- if checked == True:
+ if pText == "Raster Map" :
self.cmd= ['d.rast', str("map=" + self.mapname)]
- maplayer = self.MapWindow.Map.AddLayer(type='raster', name=self.mapname, command=self.cmd)
- self.layer_selected = maplayer
- self.type = 'raster'
- 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()
-
-
+ 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 pText == "Vector Map" :
- if checked == True:
- self.cmd= ['d.vect', str("map=" + self.mapname),str('color=' + self.colour)]
- if self.colour_selected == False:
- maplayer = self.MapWindow.Map.AddLayer(type='vector', name=self.mapname, command=self.cmd)
- else:
- self.colour_selected = False
- layers = self.MapWindow.Map.GetListOfLayers( l_type='vector', l_name=self.mapname)
- for layer in layers:
- maplayer=layer.__init__(type='vector', name=self.mapname, cmd=self.cmd)
- self.layer_selected = maplayer
- self.type = 'vector'
- 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
+ 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)
+ 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)
@@ -287,16 +217,15 @@
glocs = glob.glob(os.path.join(self.gisdbase,location, mapset,"*"))
for gloc in glocs:
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)
- elif(os.path.basename(gloc)=='vector'):
- for vect in glob.glob(os.path.join(self.gisdbase,location, mapset,gloc, "*")):
- vectormap = self.PrependItem(node_vector, os.path.basename(vect),ct_type=1)
- self.PrependItem(vectormap, "colour")
- 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)
+ 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)
+ 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)
+ 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)
#Nodes with no children are given an italic type font
for node in treeNodes:
@@ -314,7 +243,13 @@
self.SortChildren(node_vector)
self.SortChildren(node_dbf)
+ def OnToggleExpand(self,event):
+ if self.treeExpand.GetValue() == True:
+ self.ExpandAll()
+ else:
+ self.CollapseAll()
+
def OnBeginRename(self,event):
item = self.GetItemText(event.GetItem())
@@ -348,33 +283,16 @@
Display a popupMenu for copy,rename & delete operations
"""
item = event.GetItem()
- parent = self.GetItemParent(item)
- pText = self.GetItemText(parent)
- # if not self.ItemHasChildren(item) and \
- # self.GetItemFont(item) != self.itemFont:
- if self.GetItemText(item)!='Raster Map' and \
- self.GetItemText(item)!='Vector Map' and \
- self.GetItemText(item)!='DBF' and \
- self.GetItemFont(item) != self.itemFont:
+ if not self.ItemHasChildren(item) and \
+ self.GetItemFont(item) != self.itemFont:
+
self.popupmenu = wx.Menu()
mnuCopy = self.popupmenu.Append(self.ID_COPY,'&Copy\tCtrl+C')
mnuRename = self.popupmenu.Append(self.ID_REN,'&Rename\tCtrl-R')
mnuDel = self.popupmenu.Append(self.ID_DEL,'&Delete\tDEL')
- #self.popupmenu.AppendSeperator()
- mnuOssim = self.popupmenu.Append(self.ID_OSSIM,'&Send to OssimPlanet')
- mnuOssim = self.popupmenu.Append(self.ID_OSSIM2,'&Remove from OssimPlanet')
- #self.popupmenu.AppendSeperator()
+ mnuOssim = self.popupmenu.Append(self.ID_OSSIM,'&send to OssimPlanet')
mnuInfo = self.popupmenu.Append(self.ID_INFO,'&Info')
-
- if pText == 'Vector Map':
- mnuReport = wx.Menu()
- mnuReport.Append(self.ID_AREA, 'Area')
- mnuReport.Append(self.ID_LENGTH, 'Length')
- mnuReport.Append(self.ID_COOR, 'Coordinate')
- self.popupmenu.AppendMenu(wx.ID_ANY, 'Report', mnuReport)
- else:
- mnuReport =self.popupmenu.Append(self.ID_REPORT,'&Report')
-
+ mnuReport = self.popupmenu.Append(self.ID_REPORT,'&Report')
self.PopupMenu(self.popupmenu)
@@ -484,54 +402,20 @@
Performs grass command for deleting a map
"""
item = self.GetSelection()
- cmdflag = None
+
parent =self.GetItemParent(item)
if self.GetItemText(parent) == "Raster Map" :
- #print str(self.GetItemText(item))
cmdflag = 'r.planet.py -a map=' + str(self.GetItemText(item))
- else:
- # child,cookie = self.GetNextChild(item,cookie=1)
- if self.GetItemText(item) == 'colour':
- col=self.GetItemTextColour(item)
- else:
- child,cookie = self.GetFirstChild(item)
- col = self.GetItemTextColour(child)
- if col.IsOk() is True:
- col=str(col)
- col = col.replace('(','')
- col = col.replace(')','')
- col = col.split(',')
+ elif self.GetItemText(parent) == "Vector Map" :
+ cmdflag = 'v.planet.py -a map=' + str(self.GetItemText(item))
- cmdflag = 'v.planet.py -a map=' + str(self.GetItemText(item)) + \
- ' brush=' + str(col[0].strip()+','+col[1].strip()+','+col[2].strip()) + \
- ' pen=' + str(col[0].strip()+','+col[1].strip()+','+col[2].strip()) + ' size=' +str('1,1')
- print cmdflag
-
- if cmdflag is not None:
+ if cmdflag:
+
+ #command = ["r.planet.py", cmdflag]
+ #gcmd.CommandThread(command,stdout=None,stderr=None).run()
current = OssimPlanet(cmdflag)
current.start()
-
-
- def OnOssim2( self,event ):
- """
- Performs grass command for deleting a map
- """
- item = self.GetSelection()
- cmdflag = None
- parent =self.GetItemParent(item)
- if self.GetItemText(parent) == "Raster Map" :
- cmdflag = 'r.planet.py -r map=' + str(self.GetItemText(item))
- else:
- if self.GetItemText(item) == 'colour':
- previtem = self.GetItemParent(item)
- cmdflag = 'v.planet.py -r map=' + str(self.GetItemText(previtem))
- else:
- cmdflag = 'v.planet.py -r map=' + str(self.GetItemText(item))
-
- if cmdflag is not None:
- current = OssimPlanet(cmdflag)
- current.start()
def OnDisplay(self, event):
Modified: grass-addons/gui/wxpython/data_catalog/catalog.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/catalog.py 2010-04-30 18:56:50 UTC (rev 42068)
+++ grass-addons/gui/wxpython/data_catalog/catalog.py 2010-05-01 08:57:41 UTC (rev 42069)
@@ -36,7 +36,7 @@
gbase = os.getenv("GISBASE")
-pypath = os.path.join(gbase,'etc','wxpython')
+pypath = os.path.join(gbase,'etc','gui','wxpython')
sys.path.append(pypath)
@@ -56,7 +56,7 @@
#To run DataCatalog from any directory set this pathname for access to gui_modules
gbase = os.getenv("GISBASE")
-pypath = os.path.join(gbase,'etc','wxpython','gui_modules')
+pypath = os.path.join(gbase,'etc','gui','wxpython','gui_modules')
sys.path.append(pypath)
@@ -88,7 +88,7 @@
import gui_modules.colorrules as colorrules
version = os.getenv("GRASS_VERSION")
-if version == "6.5.svn":
+if version != "6.4.svn":
import gui_modules.menu as menu
import gui_modules.gmodeler as gmodeler
@@ -176,7 +176,7 @@
#self.pg_panel4 = None
version = os.getenv("GRASS_VERSION")
- if version == "6.5.svn":
+ if version != "6.4.svn":
self.menubar = menu.Menu(parent = self, data = menudata.ManagerData())
else:
self.menubar, self.menudata = self.__createMenuBar()
@@ -187,8 +187,8 @@
#setting splitter window
self.cmbPanel = wx.Panel(self,name="cmbpanel")
+
-
self.maptree = None
self.pg_panel = None
self.cb_loclist = []
@@ -196,18 +196,16 @@
self.cb_mapfile = []
#creating controls
+
self.mInfo = wx.TextCtrl(self.cmbPanel, wx.ID_ANY, style = wx.TE_READONLY,size=(300,30))
#
# start radiobutton to activate - deactivate the mouse actions to send position to ossimplanet
#
self.options = ['on', 'off']
- self.radiobox = wx.RadioBox(self.cmbPanel, wx.ID_ANY, "", choices=self.options, style=wx.HORIZONTAL)
+ self.radiobox = wx.RadioBox(self.cmbPanel, wx.ID_ANY, choices=self.options, style=wx.HORIZONTAL)
self.radiobox.SetSelection(1)
- #
- #
#self.chkInfo = wx.CheckBox(self.cmbPanel, wx.ID_ANY,"display Info", wx.DefaultPosition, wx.DefaultSize)
self.treeExpand = wx.CheckBox(self.cmbPanel, wx.ID_ANY,"Expand All", wx.DefaultPosition, wx.DefaultSize)
- #self.treeExpand2 = wx.CheckBox(self.cmbPanel, wx.ID_ANY,"Expand All 2", wx.DefaultPosition, wx.DefaultSize)
self.cmbLocation = wx.ComboBox(self.cmbPanel, value = "Select Location",size=wx.DefaultSize, choices=self.loclist)
self.cmbMapset = wx.ComboBox(self.cmbPanel, value = "Select Mapset", size=wx.DefaultSize)
#self.tree = wx.TreeCtrl(self.pLeft, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS)
@@ -1969,7 +1967,7 @@
self.page = self.notebook.GetPage(self.notebook.GetSelection())
self.page.Map.__init__()
self.page.Map.region = self.page.Map.GetRegion()
- if version == "6.5.svn":
+ if version != "6.4.svn":
self.page.Map.projinfo = self.page.Map._projInfo()
else:
self.page.Map.projinfo = self.page.Map.ProjInfo()
@@ -2036,16 +2034,19 @@
return loclist
-
def doBindings(self):
#Event bindings for combo boxes
self.Bind(wx.EVT_COMBOBOX,self.OnMapsetChange,self.cmbMapset)
self.Bind(wx.EVT_COMBOBOX,self.OnLocationChange,self.cmbLocation)
+
+
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
-
+ #Event bindings for v/r.info checkbox
+ #self.Bind(wx.EVT_CHECKBOX, self.OnToggleInfo,self.chkInfo)
+
def doLayout(self):
@@ -2054,7 +2055,6 @@
self.cmbSizer.Add(self.cmbMapset)
self.cmbSizer.Add(self.mInfo)
self.cmbSizer.Add(self.radiobox)
- #splitter window sizers
self.mSizer.Add(self.cmbPanel,flag=wx.EXPAND)
#self.mSizer.Add(self.win, 1, wx.EXPAND)
#self.leftSizer.Add(self.ltree,1,wx.EXPAND)
Modified: grass-addons/gui/wxpython/data_catalog/mapdisplay.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-04-30 18:56:50 UTC (rev 42068)
+++ grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-05-01 08:57:41 UTC (rev 42069)
@@ -32,7 +32,6 @@
import tempfile
import copy
import time
-from tcp4ossim import zoomto
@@ -1987,7 +1986,6 @@
self.Map.AlignExtentFromDisplay()
# update map
- self.flag =True
self.UpdateMap()
# update statusbar
@@ -2432,11 +2430,7 @@
self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, gismgr=self._layerManager)
# default is 2D display mode
self.MapWindow = self.MapWindow2D
- self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
- self.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
- self.MapWindow.Bind(wx.EVT_RADIOBOX, self.printsomething)
- # test for right click mouse event
- #self.MapWindow.Bind(wx.EVT_RIGHT_DOWN, self.OnClick3)
+ #self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
self.MapWindow.SetCursor(self.cursors["default"])
# used by Nviz (3D display mode)
self.MapWindow3D = None
@@ -2528,58 +2522,12 @@
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()
-
-
#r.rightSizer.Add(self.maptree)
-
- def OnClick(self,event):
- if self.frame.radiobox.GetSelection() == 0:
- x, y = self.MapWindow.Pixel2Cell(event.GetPosition())
- out = subprocess.Popen(['m.proj', '-o'], stdout=subprocess.PIPE, stdin=subprocess.PIPE).communicate("%s %s" % (x,y))[0]
- f = out.replace("'"," ").replace('d',' ').replace('"',' ').replace('\n','').split('\t')
- lon = f[0].split(' ')
- lat = f[1].split(' ')[:-1]
- if lat[-1] == 'N':
- signlat = 1
- if lat[-1] == 'S':
- signlat = -1
- if lon[-1] == 'E':
- signlon = 1
- if lon[-1] == 'W':
- signlon = -1
- lat = (float(lat[0]) + (float(lat[1]) / 60) + float(lat[2]) / 3600) * float(signlat)
- lon = (float(lon[0]) + (float(lon[1]) / 60) + float(lon[2]) / 3600) * float(signlon)
- self.frame.mInfo.SetValue(str(lat) + ' , ' + str(lon))
- zoomto(str(lon),str(lat),15000)
- event.Skip()
-
-
-
- def OnClick2(self,event):
- x, y = self.MapWindow.Pixel2Cell(event.GetPosition())
- self.frame.mInfo.SetValue(str(x) + ' , ' + str(y))
- event.Skip()
-
-
- # test for right click mouse event
- def OnClick3(self,event):
- x, y = self.MapWindow.Pixel2Cell(event.GetPosition())
- self.frame.mInfo.SetValue(str(x) + ' , ' + str(y))
- event.Skip()
-
- # test for radiobox
- def printsomething(self,event):
- stringa = 'ffffff'
- self.frame.mInfo.SetValue(str(stringa))
- print stringa
- event.Skip()
-
-
def read_gisrc(self):
"""
Read variables gisrc file
@@ -2940,7 +2888,6 @@
"""
Pointer button clicked
"""
-
if self.toolbars['map']:
if event:
self.toolbars['map'].OnTool(event)
More information about the grass-commit
mailing list