[GRASS-SVN] r35034 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 26 10:59:03 EST 2008
Author: martinl
Date: 2008-12-26 10:59:03 -0500 (Fri, 26 Dec 2008)
New Revision: 35034
Modified:
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/gselect.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: various fixes
vdigit: fix left mouse button click when moving vertex/line
sort columns in ColumnSelect
use grass module
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2008-12-26 15:52:19 UTC (rev 35033)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2008-12-26 15:59:03 UTC (rev 35034)
@@ -273,8 +273,8 @@
data = buffer(data, sent)
class Command:
- """
- Run GRASS command in separate thread
+ """Run command in separate thread. Used for commands launched
+ on the background.
If stdout/err is redirected, write() method is required for the
given classes.
@@ -289,21 +289,21 @@
else:
print 'FAILURE (%d)' % cmd.returncode
@endcode
-
- @param cmd command given as list
- @param stdin standard input stream
- @param verbose verbose level [0, 3] (--q, --v)
- @param wait wait for child execution terminated
- @param rerr error handling (when CmdError raised).
- True for redirection to stderr, False for GUI dialog,
- None for no operation (quiet mode)
- @param stdout redirect standard output or None
- @param stderr redirect standard error output or None
"""
def __init__ (self, cmd, stdin=None,
verbose=None, wait=True, rerr=False,
stdout=None, stderr=None):
-
+ """
+ @param cmd command given as list
+ @param stdin standard input stream
+ @param verbose verbose level [0, 3] (--q, --v)
+ @param wait wait for child execution terminated
+ @param rerr error handling (when CmdError raised).
+ True for redirection to stderr, False for GUI dialog,
+ None for no operation (quiet mode)
+ @param stdout redirect standard output or None
+ @param stderr redirect standard error output or None
+ """
self.cmd = cmd
self.stderr = stderr
@@ -478,16 +478,16 @@
return msgString
class CommandThread(Thread):
- """Create separate thread for command
-
- @param cmd GRASS command (given as list)
- @param stdin standard input stream
- @param stdout redirect standard output or None
- @param stderr redirect standard error output or None
- """
+ """Create separate thread for command. Used for commands launched
+ on the background."""
def __init__ (self, cmd, stdin=None,
stdout=sys.stdout, stderr=sys.stderr):
-
+ """
+ @param cmd command (given as list)
+ @param stdin standard input stream
+ @param stdout redirect standard output or None
+ @param stderr redirect standard error output or None
+ """
Thread.__init__(self)
self.cmd = cmd
@@ -514,6 +514,7 @@
del os.environ["GRASS_MESSAGE_FORMAT"]
def run(self):
+ """Run command"""
if len(self.cmd) == 0:
return
Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py 2008-12-26 15:52:19 UTC (rev 35033)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py 2008-12-26 15:59:03 UTC (rev 35034)
@@ -336,38 +336,28 @@
for layer in self.layers.keys():
# determine column names and types
table = self.layers[layer]["table"]
- columnsCommand = gcmd.Command (cmd=["db.describe",
- "-c", "--q",
- "table=%s" % self.layers[layer]["table"],
- "driver=%s" % self.layers[layer]["driver"],
- "database=%s" % self.layers[layer]["database"]])
-
-
columns = {} # {name: {type, length, [values], [ids]}}
+ i = 0
+ for item in grass.db_describe(table = self.layers[layer]["table"],
+ driver = self.layers[layer]["driver"],
+ database = self.layers[layer]["database"])['cols']:
+ name, type, length = item
+ # FIXME: support more datatypes
+ if type.lower() == "integer":
+ ctype = int
+ elif type.lower() == "double precision":
+ ctype = float
+ else:
+ ctype = str
- if columnsCommand.returncode == 0:
- # skip nrows and ncols
- i = 0
- for line in columnsCommand.ReadStdOutput()[2:]:
- num, name, type, length = line.strip().split(':')
- # FIXME: support more datatypes
- if type.lower() == "integer":
- ctype = int
- elif type.lower() == "double precision":
- ctype = float
- else:
- ctype = str
-
- columns[name.strip()] = { 'index' : i,
- 'type' : type.lower(),
- 'ctype' : ctype,
- 'length' : int(length),
- 'values' : [],
- 'ids' : []}
- i += 1
- else:
- return False
-
+ columns[name.strip()] = { 'index' : i,
+ 'type' : type.lower(),
+ 'ctype' : ctype,
+ 'length' : int(length),
+ 'values' : [],
+ 'ids' : []}
+ i += 1
+
# check for key column
# v.db.connect -g/p returns always key column name lowercase
if self.layers[layer]["key"] not in columns.keys():
@@ -530,10 +520,13 @@
try:
table = dbInfo.layers[int(layer)]['table']
columnchoices = dbInfo.tables[table]
+ columns = len(columnchoices.keys()) * ['']
+ for key, val in columnchoices.iteritems():
+ columns[val['index']] = key
except (KeyError, ValueError):
- columnchoices = {}
-
- self.SetItems(columnchoices.keys())
+ columns = []
+
+ self.SetItems(columns)
self.SetValue('')
class DbColumnSelect(wx.ComboBox):
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-12-26 15:52:19 UTC (rev 35033)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-12-26 15:59:03 UTC (rev 35034)
@@ -742,7 +742,7 @@
item = self.tree.FindItemByData('maplayer', digitToolbar.GetLayer())
except TypeError:
item = None
-
+
if item and self.tree.IsItemChecked(item):
self.parent.digit.driver.DrawMap()
@@ -1088,12 +1088,14 @@
move = (current[0] - previous[0],
current[1] - previous[1])
+ digitToolbar = self.parent.toolbars['vdigit']
+
# dragging or drawing box with left button
if self.mouse['use'] == 'pan':
self.DragMap(move)
# dragging decoration overlay item
- elif (self.mouse['use'] == 'pointer' and not self.parent.toolbars['vdigit']) and \
+ elif (self.mouse['use'] == 'pointer' and not digitToolbar) and \
self.dragid != None and \
self.dragid != 99:
self.DragItem(self.dragid, event)
@@ -1101,7 +1103,11 @@
# dragging anything else - rubber band box or line
else:
self.mouse['end'] = event.GetPositionTuple()[:]
- if event.LeftIsDown():
+ digitClass = self.parent.digit
+ if event.LeftIsDown() and not \
+ (digitToolbar and \
+ digitToolbar.GetAction() in ("moveLine",) and \
+ digitClass.driver.GetSelected() > 0):
# draw box only when left mouse button is pressed
self.MouseDraw(pdc=self.pdcTmp)
@@ -1440,11 +1446,11 @@
if hasattr(self, "vdigitMove"):
if len(digitClass.driver.GetSelected()) == 0:
self.vdigitMove['begin'] = pos1 # left down
- else:
- dx = pos2[0] - pos1[0] ### ???
- dy = pos2[1] - pos1[1]
- self.vdigitMove = (self.vdigitMove['begin'][0] + dx,
- self.vdigitMove['begin'][1] + dy)
+ ### else:
+ ### dx = pos2[0] - pos1[0] ### ???
+ ### dy = pos2[1] - pos1[1]
+ ### self.vdigitMove = (self.vdigitMove['begin'][0] + dx,
+ ### self.vdigitMove['begin'][1] + dy)
# eliminate initial mouse moving efect
self.mouse['begin'] = self.mouse['end']
@@ -1532,7 +1538,7 @@
if digitClass.driver.SelectLineByPoint(pos1,
digitClass.GetSelectType()) is not None:
nselected = 1
-
+
if nselected > 0:
if digitToolbar.GetAction() in ["moveLine", "moveVertex"]:
# get pseudoDC id of objects which should be redrawn
@@ -1570,7 +1576,10 @@
self.UpdateMap(render=False)
else: # no vector object found
- self.UpdateMap(render=False, renderVector=False)
+ if not (digitToolbar.GetAction() in ["moveLine", "moveVertex"] and \
+ len(self.vdigitMove['id']) > 0):
+ # avoid left-click when features are already selected
+ self.UpdateMap(render=False, renderVector=False)
elif digitToolbar.GetAction() in ["splitLine", "addVertex", "removeVertex"]:
pointOnLine = digitClass.driver.SelectLineByPoint(pos1,
@@ -2032,7 +2041,7 @@
x, y = self.Pixel2Cell(self.pdcTmp.GetIdBounds(self.vdigitMove['id'][2])[0:2])
self.pdcTmp.RemoveId(self.vdigitMove['id'][2]-1)
self.polycoords.append((x, y))
-
+
self.ClearLines(pdc=self.pdcTmp)
self.DrawLines(pdc=self.pdcTmp)
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2008-12-26 15:52:19 UTC (rev 35033)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2008-12-26 15:59:03 UTC (rev 35034)
@@ -2415,27 +2415,24 @@
def UpdateVectorPage(self, layer, data):
vInfo = gcmd.Command(['v.info',
+ '-t',
'map=%s' % layer.name])
npoints = nprimitives = 0
for line in vInfo.ReadStdOutput():
- if 'Map is 3D' in line:
- mapIs3D = line.replace('|', '').split(':')[1].strip()
- if mapIs3D == 'Yes':
- mapIs3D = 1
- else:
- mapIs3D = 0
- elif 'Number of points' in line:
- npoints = int(line.replace('|', '').split(':')[1].strip().split(' ')[0])
+ key, value = line.split('=')
+ if key == 'map3d':
+ mapIs3D = int(value)
+
+ elif key == 'points':
+ npoints = int(value)
nprimitives = npoints
- elif 'Number of lines' in line:
- nprimitives += int(line.replace('|', '').split(':')[1].strip().split(' ')[0])
- elif 'Number of boundaries' in line:
- nprimitives += int(line.replace('|', '').split(':')[1].strip().split(' ')[0]) # boundaries
- nprimitives += int(line.replace('|', '').split(':')[2].strip()) # faces
- elif 'Number of centroids' in line:
- nprimitives += int(line.replace('|', '').split(':')[1].strip().split(' ')[0]) # centroids
- nprimitives += int(line.replace('|', '').split(':')[2].strip()) # kernels
-
+ elif key in ('lines',
+ 'boundaries',
+ 'centroids',
+ 'faces',
+ 'kernels'):
+ nprimitives += int(value)
+
if mapIs3D:
desc = _("Vector map <%s> is 3D") % layer.name
enable = False
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-12-26 15:52:19 UTC (rev 35033)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-12-26 15:59:03 UTC (rev 35034)
@@ -291,8 +291,10 @@
#create main notebook widget
nbStyle = FN.FNB_FANCY_TABS | \
- FN.FNB_BOTTOM | \
- FN.FNB_NO_NAV_BUTTONS
+ FN.FNB_BOTTOM | \
+ FN.FNB_NO_NAV_BUTTONS | \
+ FN.FNB_NO_X_BUTTON
+
self.notebook = FN.FlatNotebook(parent=self, id=wx.ID_ANY, style=nbStyle)
#self.notebook = wx.aui.AuiNotebook(parent=self, id=wx.ID_ANY, style=wx.aui.AUI_NB_BOTTOM)
@@ -517,7 +519,7 @@
authorsFile = open(os.path.join(os.getenv("GISBASE"), "AUTHORS"), 'r')
info.SetDevelopers([unicode(''.join(authorsFile.readlines()), "utf-8")])
authorsFile.close()
-
+
wx.AboutBox(info)
def OnWorkspace(self, event):
@@ -1421,16 +1423,16 @@
name = str(self.curr_page.maptree.GetItemText(item))
idx = name.find('(opacity')
if idx > -1:
- layerName += '<' + name[:idx].strip(' ') + '>, '
+ layerName += '<' + name[:idx].strip(' ') + '>,\n'
else:
- layerName += '<' + name + '>, '
- layerName = layerName.rstrip(', ')
+ layerName += '<' + name + '>,\n'
+ layerName = layerName.rstrip(',\n')
- if layerName:
- message = _("Do you want to remove map layer %s "
+ if len(layerName) > 2: # <>
+ message = _("Do you want to remove map layer(s)\n%s\n"
"from layer tree?") % layerName
else:
- message = _("Do you want to remove selected map layer "
+ message = _("Do you want to remove selected map layer(s) "
"from layer tree?")
dlg = wx.MessageDialog (parent=self, message=message,
More information about the grass-commit
mailing list