[GRASS-SVN] r41117 - grass-addons/gui/wxpython/data_catalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 19 06:36:32 EST 2010
Author: rashadkm
Date: 2010-02-19 06:36:31 -0500 (Fri, 19 Feb 2010)
New Revision: 41117
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
grass-addons/gui/wxpython/data_catalog/wx_utils.py
Log:
minor updates only;
Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-02-19 09:18:52 UTC (rev 41116)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-02-19 11:36:31 UTC (rev 41117)
@@ -228,7 +228,7 @@
parent =self.GetItemParent(item)
if self.GetItemText(parent) == "Raster Map" :
cmdflag = 'rast=' + str(self.GetItemText(item))
- elif self.tree.GetItemText(parent) == "Vector Map" :
+ elif self.GetItemText(parent) == "Vector Map" :
cmdflag = 'vect=' + str(self.GetItemText(item))
if cmdflag:
@@ -251,7 +251,7 @@
parent =self.GetItemParent(item)
if self.GetItemText(parent) == "Raster Map" :
cmdflag = 'r.planet.py -a map=' + str(self.GetItemText(item))
- elif self.tree.GetItemText(parent) == "Vector Map" :
+ elif self.GetItemText(parent) == "Vector Map" :
cmdflag = 'v.planet.py -a map=' + str(self.GetItemText(item))
if cmdflag:
@@ -262,23 +262,9 @@
current.start()
-
-
- def OnCloseWindow(self,event):
-
- if self.gisrc['LOCATION_NAME'] != self.iLocation or \
- self.gisrc['MAPSET'] != self.iMapset:
- self.gisrc['LOCATION_NAME'] = self.iLocation
- self.gisrc['MAPSET'] = self.iMapset
- self.update_grassrc(self.gisrc)
-
- self.Map.Clean()
- event.Skip()
- #self.Destroy()
-
-
def OnDisplay(self, event):
+
item = event.GetItem()
pText = self.GetItemText(self.GetItemParent(item))
@@ -290,31 +276,42 @@
winlist = window2.GetChildren()
for win in winlist:
if type(win) == wx.lib.flatnotebook.FlatNotebook:
+ #win.SetSelection(0)
child=win.GetChildren()
for panel in child:
if panel.GetName() == "pg_panel":
- ss = panel.GetName()
+ mapframe = panel
+ # mtree = mapframe.maptree
+ #print mtree.GetName()
+
-
if not self.ItemHasChildren(item):
- self.mapname = "map=" + self.GetItemText(item) + "@" + frame.cmbMapset.GetValue()
- #self.mapname = "map=" + self.GetItemText(item) + "@PERMANENT"
+ self.mapname = self.GetItemText(item) + "@" + frame.cmbMapset.GetValue()
+ #for f in frames:
+ # print f.GetName()
+
if pText == "Raster Map" :
- self.cmd= ['d.rast', str(self.mapname)]
- self.infocmd = ["r.info", str(self.mapname)]
+ self.cmd= ['d.rast', str("map=" + self.mapname)]
+ mapframe.maptree.AddLayer(ltype="raster", lname=self.mapname, lchecked=True,lcmd=self.cmd)
+ l_type="raster"
+ #self.infocmd = ["r.info", str(self.mapname)]
elif pText == "Vector Map" :
- self.cmd= ['d.vect', str(self.mapname)]
- self.infocmd = ["v.info", str(self.mapname)]
+ self.cmd= ['d.vect', str("map=" + self.mapname)]
+ mapframe.maptree.AddLayer(ltype="vector", lname=self.mapname, lchecked=True,lcmd=self.cmd)
+ l_type="vector"
+ #self.infocmd = ["r.info", str(self.mapname)]
+
- if self.cmd:
- panel.Map.Clean()
- panel.Map.__init__() #to update projection and region
- panel.Map.AddLayer(type='raster', name='layer1', command=self.cmd)
- panel.Map.region = panel.Map.GetRegion()
- panel.MapWindow2D.flag = True
- panel.MapWindow2D.UpdateMap(render=True)
+ # if self.cmd:
+ # mapframe.Map.Clean()
+ # mapframe.Map.__init__() #to update projection and region
+ # mapframe.Map.AddLayer(type=l_type, name='layer1', command=self.cmd)
+ # mapframe.Map.region = panel.Map.GetRegion()
+ # mapframe.MapWindow2D.flag = True
+ # mapframe.MapWindow2D.UpdateMap(render=True)
+
class OssimPlanet(Thread):
def __init__ (self,cmd):
Thread.__init__(self)
Modified: grass-addons/gui/wxpython/data_catalog/catalog.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/catalog.py 2010-02-19 09:18:52 UTC (rev 41116)
+++ grass-addons/gui/wxpython/data_catalog/catalog.py 2010-02-19 11:36:31 UTC (rev 41117)
@@ -28,7 +28,6 @@
import getopt
import platform
import shlex
-import gc
try:
import xml.etree.ElementTree as etree
@@ -108,7 +107,7 @@
def __init__(self, parent=None, id=wx.ID_ANY, title=_("Data Catalog"),
workspace=None,size=wx.DefaultSize,pos=wx.DefaultPosition):
- gc.enable()
+
self.iconsize = (16, 16)
self.baseTitle = title
@@ -169,9 +168,9 @@
#setting splitter window
self.win = wx.SplitterWindow(self)
- self.pLeft = wx.Panel(self.win, style=wx.SUNKEN_BORDER)
+ self.pLeft = wx.Panel(self.win, style=wx.SUNKEN_BORDER,name="leftpanel")
self.pRight = wx.Panel(self.win, style=wx.SUNKEN_BORDER,name="rightpanel")
- self.cmbPanel = wx.Panel(self)
+ self.cmbPanel = wx.Panel(self,name="cmbpanel")
self.rightPanel = wx.Panel(self.pRight)
self.pRight.SetBackgroundColour("white")
self.pLeft.Hide()
@@ -231,11 +230,12 @@
self.books = self.splitter.GetChildren()
for self.book in self.books:
if type(self.book) == wx.lib.flatnotebook.FlatNotebook:
+ ##self.book.SetSelection(self.book.GetCurrentPage())
self.panel = self.book.GetChildren()
for self.subpanel in self.panel:
if self.subpanel.GetName() == "pg_panel":
- self.mapnew = self.subpanel.Map
- return self.mapnew
+ self.newmap = self.subpanel.Map
+ return self.newmap
def __createMenuBar(self):
@@ -257,38 +257,44 @@
"""!Creates command-line input area"""
self.cmdprompt = wx.Panel(self)
- label = wx.StaticText(parent=self.cmdprompt, id=wx.ID_ANY, label="Cmd >")
+ button = wx.Button(parent=self.cmdprompt, id=wx.ID_ANY, label="Cmd >",
+ size=(70,23))
+ button.SetToolTipString(_("Click for erasing command prompt"))
# label.SetFont(wx.Font(pointSize=11, family=wx.FONTFAMILY_DEFAULT,
# style=wx.NORMAL, weight=wx.BOLD))
- input = wx.TextCtrl(parent=self.cmdprompt, id=wx.ID_ANY,
+ self.cinput = wx.TextCtrl(parent=self.cmdprompt, id=wx.ID_ANY,
value="",
- style=wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER,
- size=(-1, 25))
+ style= wx.TE_PROCESS_ENTER,
+ size=(250,20))
- input.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, ''))
+ #cinput.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, ''))
- wx.CallAfter(input.SetInsertionPoint, 0)
+ wx.CallAfter(self.cinput.SetInsertionPoint, 0)
- self.Bind(wx.EVT_TEXT_ENTER, self.OnRunCmd, input)
+ self.Bind(wx.EVT_TEXT_ENTER, self.OnRunCmd, self.cinput)
+ self.Bind(wx.EVT_BUTTON, self.OnCmdClear, button)
#self.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar, input)
# layout
sizer = wx.BoxSizer(wx.HORIZONTAL)
- sizer.Add(item=label, proportion=0,
+ sizer.Add(item=button, proportion=0,
flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER,
border=4)
- sizer.Add(item=input, proportion=1,
+ sizer.Add(item=self.cinput, proportion=1,
flag=wx.EXPAND | wx.ALL,
border=1)
self.cmdprompt.SetSizer(sizer)
- sizer.Fit(self.cmdprompt)
+ #sizer.Fit(self.cmdprompt)
self.cmdprompt.Layout()
return self.cmdprompt
- return p.GetPanel(), p.GetInput()
+ def OnCmdClear(self,event):
+ self.cinput.SetValue('')
+ self.cinput.SetFocus()
+
def __createMenu(self, menuData):
"""!Creates menu"""
@@ -360,19 +366,19 @@
self.Bind(wx.EVT_MENU, rhandler, menuItem)
def OnXTerm(self):
- print "asdf"
+ print "asdf1"
def OnRunScript(self):
- print "asdf"
+ print "asdf2"
def OnQuit(self):
- print "asdf"
+ print "asdf3"
def OnRunCmd(self, event):
"""Run command"""
cmdString = event.GetString()
- if cmdString[:2] == 'd.' and not self.curr_page:
+ if cmdString[:2] == 'd.' and not self.current:
self.NewDisplay(show=True)
cmd = shlex.split(str(cmdString))
@@ -389,7 +395,7 @@
# self.statusbar.SetStatusText("")
#else:
# self.statusbar.SetStatusText(_("Type GRASS command and run by pressing ENTER"))
- print "asdf"
+ print "asdf4"
def __createToolBar(self):
@@ -434,12 +440,12 @@
# create displays notebook widget and add it to main notebook page
cbStyle = globalvar.FNPageStyle
- self.notebook = FN.FlatNotebook(parent=self.pRight, id=wx.ID_ANY, style=cbStyle,name="mynotebook")
+ self.notebook = FN.FlatNotebook(parent=self.pRight, id=wx.ID_ANY, style=cbStyle)
self.notebook.SetTabAreaColour(globalvar.FNPageColor)
-
- self.pg_panel = MapFrame(parent=self.notebook, id=wx.ID_ANY, Map=render.Map(), size=globalvar.MAP_WINDOW_SIZE,frame=self,flag=True)
+ # self._lmgr=wx.aui.AuiManager(self)
+ self.pg_panel = MapFrame(parent=self.notebook, id=wx.ID_ANY, Map=render.Map(), size=globalvar.MAP_WINDOW_SIZE,frame=self,flag=True,gismgr=self)
self.disp_idx = self.disp_idx + 1
self.notebook.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx), select = True)
@@ -480,7 +486,9 @@
pass
def OnPageChanged(self,event):
- self.current = event.GetSelection()
+ self.current = self.notebook.GetPage(event.GetSelection())
+ #self.current = self.notebook.GetCurrentPage()
+ #self.current.Map = self.GetMapDisplay()
event.Skip()
@@ -526,7 +534,7 @@
self.disp_idx = self.disp_idx - 1
self.notebook.DeletePage(self.notebook.GetCurrentPage())
self.current = self.notebook.GetCurrentPage()
- self.current.Map.Clean()
+ #self.current.Map.Clean()
event.Skip()
@@ -590,6 +598,8 @@
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:
@@ -1760,8 +1770,13 @@
# Run the program
if __name__ == "__main__":
+
+
+ #gc.enable()
+ #gc.set_debug(gc.DEBUG_LEAK)
g_catalog = CatalogApp(0)
g_catalog.MainLoop()
+
#sys.exit(0)
Modified: grass-addons/gui/wxpython/data_catalog/mapdisplay.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-02-19 09:18:52 UTC (rev 41116)
+++ grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-02-19 11:36:31 UTC (rev 41117)
@@ -57,7 +57,7 @@
sys.path.append(grassPath)
import render
-import toolbars1
+import toolbars
import menuform
import gselect
import disp_print
@@ -68,6 +68,7 @@
import globalvar
import utils
import gdialogs
+import goutput
from grass.script import core as grass
from debug import Debug
from preferences import globalSettings as UserSettings
@@ -110,7 +111,7 @@
@param Map instance of render.Map
"""
self.gismanager = gismgr # Layer Manager object
- self._layerManager = self.gismanager
+ self._layerManager = gismgr
self.Map = Map # instance of render.Map
self.tree = tree # Layer Manager layer tree object
self.page = page # Notebook page holding the layer tree
@@ -120,7 +121,7 @@
self.statusFlag = flag
self.statusbar = None
-
+ #FIX THIS
#
@@ -157,7 +158,13 @@
# Fancy gui
#
# self._mgr = auimgr
+
+
+
self._mgr = wx.aui.AuiManager(self)
+
+ #self._layerManager.goutput = goutput.GMConsole(self.parent.GetParent(), pageid=1)
+ #self._layerManager.goutput.Hide()
#
# Add toolbars
@@ -269,6 +276,7 @@
#
# Init map display (buffered DC & set default cursor)
#
+
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
@@ -378,7 +386,7 @@
"""
# default toolbar
if name == "map":
- self.toolbars['map'] = toolbars1.MapToolbar(self, self.Map)
+ self.toolbars['map'] = toolbars.MapToolbar(self, self.Map)
self._mgr.AddPane(self.toolbars['map'].toolbar,
wx.aui.AuiPaneInfo().
@@ -491,8 +499,8 @@
# create GL window & NVIZ toolbar
#
if not self.MapWindow3D:
- self.MapWindow3D = nviz.GLWindow(self, id=wx.ID_ANY,
- Map=self.Map, tree=self.tree, lmgr=self._layerManager)
+ print "xx " + self.GetName()
+ self.MapWindow3D = nviz.GLWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.maptree, gismgr=self._layerManager)
# -> show after paint
self.nvizToolWin = nviz.NvizToolWindow(self, id=wx.ID_ANY,
mapWindow=self.MapWindow3D)
Modified: grass-addons/gui/wxpython/data_catalog/wx_utils.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/wx_utils.py 2010-02-19 09:18:52 UTC (rev 41116)
+++ grass-addons/gui/wxpython/data_catalog/wx_utils.py 2010-02-19 11:36:31 UTC (rev 41117)
@@ -1,11 +1,13 @@
"""!
- at package wx_utils.py
+ at package wxgui_utils.py
@brief Utility classes for GRASS wxPython GUI. Main functions include
tree control for GIS map layer management, command console, and
command parsing.
Classes:
+ - AbstractLayer
+ - Layer
- LayerTree
(C) 2007-2009 by the GRASS Development Team
@@ -16,7 +18,7 @@
@author Michael Barton (Arizona State University)
@author Jachym Cepicky (Mendel University of Agriculture)
@author Martin Landa <landa.martin gmail.com>
- at author Mohammed Rashad K.M <rashadkm at gmail dot com> (modified for DataCatalog)
+ at author Mohammed Rashad K.M <rashadkm at gmail dot com> (only modified for DataCatalog)
"""
import os
@@ -654,6 +656,9 @@
self.first = True
params = {} # no initial options parameters
+ # import pdb
+ # pdb.set_trace()
+
# deselect active item
if self.layer_selected:
self.SelectItem(self.layer_selected, select=False)
More information about the grass-commit
mailing list