[GRASS-SVN] r65770 - in grass/trunk/gui/wxpython: gui_core tplot
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 21 22:49:38 PDT 2015
Author: lucadelu
Date: 2015-07-21 22:49:38 -0700 (Tue, 21 Jul 2015)
New Revision: 65770
Modified:
grass/trunk/gui/wxpython/gui_core/gselect.py
grass/trunk/gui/wxpython/gui_core/vselect.py
grass/trunk/gui/wxpython/tplot/frame.py
Log:
wxpython gui: fixed VectorCategorySelect, added support of VectorCategorySelect into g.gui.tplot (thank to Matej Krejci)
Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py 2015-07-21 22:36:22 UTC (rev 65769)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py 2015-07-22 05:49:38 UTC (rev 65770)
@@ -2280,7 +2280,7 @@
class VectorCategorySelect(wx.Panel):
"""Widget that allows interactive selection of vector features"""
- def __init__(self, parent, giface, task):
+ def __init__(self, parent, giface, task=None):
super(VectorCategorySelect, self).__init__(parent=parent, id=wx.ID_ANY)
self.task=task
self.parent = parent
@@ -2335,12 +2335,17 @@
"Operation canceled.") % (inputName['value'], str(layerSelected)))
return False
return True
+ return False
def _onClick(self, evt=None):
- if not self._chckMap():
- self.buttonVecSelect.SetValue(False)
- return
-
+ if self.task is not None:
+ if not self._chckMap():
+ self.buttonVecSelect.SetValue(False)
+ return
+ else:
+ if not self._isMapSelected():
+ self.buttonVecSelect.SetValue(False)
+ return
if self._vectorSelect is None:
if self.mapdisp:
@@ -2374,10 +2379,17 @@
"""Update category text input widget"""
if event == "unregistered":
return
- if not self._chckMap():
- self.OnClose()
+
+ if self.task is None:
+ if not self._isMapSelected():
+ self.OnClose()
+ else:
+ self.catsField.SetValue(self._vectorSelect.GetLineStringSelectedCats())
else:
- self.catsField.SetValue(self._vectorSelect.GetLineStringSelectedCats())
+ if not self._chckMap():
+ self.OnClose()
+ else:
+ self.catsField.SetValue(self._vectorSelect.GetLineStringSelectedCats())
def GetTextWin(self):
return self.catsField
Modified: grass/trunk/gui/wxpython/gui_core/vselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/vselect.py 2015-07-21 22:36:22 UTC (rev 65769)
+++ grass/trunk/gui/wxpython/gui_core/vselect.py 2015-07-22 05:49:38 UTC (rev 65770)
@@ -241,6 +241,9 @@
"""Return name of selected map in layer tree"""
layerList = self._giface.GetLayerList()
layerSelected = layerList.GetSelectedLayer()
+ if layerSelected is None:
+ return None
+
if not layerSelected.maplayer.IsActive():
GWarning(_("Selected map <%s> has been disabled for rendering. "
"Operation canceled.") % str(layerSelected), parent=self.mapWin)
Modified: grass/trunk/gui/wxpython/tplot/frame.py
===================================================================
--- grass/trunk/gui/wxpython/tplot/frame.py 2015-07-21 22:36:22 UTC (rev 65769)
+++ grass/trunk/gui/wxpython/tplot/frame.py 2015-07-22 05:49:38 UTC (rev 65770)
@@ -16,7 +16,7 @@
(>=v2). Read the file COPYING that comes with GRASS for details.
@author Luca Delucchi
- at author add stvds support-Matej Krejci
+ at author start stvds support Matej Krejci
"""
from itertools import cycle
import numpy as np
@@ -219,10 +219,13 @@
id=wx.ID_ANY,
label=_('Select attribute column'))
# TODO fix the category selection as done for coordinates
- #self.cats = gselect.VectorCategorySelect(parent=self.controlPanelVector,
- # giface=self._giface)
- self.cats = wx.TextCtrl(parent=self.controlPanelVector, id=wx.ID_ANY,
- size=globalvar.DIALOG_TEXTCTRL_SIZE)
+ try:
+ self._giface.GetMapWindow()
+ self.cats = gselect.VectorCategorySelect(parent=self.controlPanelVector,
+ giface=self._giface)
+ except:
+ self.cats = wx.TextCtrl(parent=self.controlPanelVector, id=wx.ID_ANY,
+ size=globalvar.DIALOG_TEXTCTRL_SIZE)
self.catsLabel = wx.StaticText(parent=self.controlPanelVector,
id=wx.ID_ANY,
label=_('Select category of vector(s)'))
@@ -336,9 +339,9 @@
self.temporalType = mode
return
- def parseVDbConn(self, map, layerInp):
+ def _parseVDbConn(self, mapp, layerInp):
'''find attribute key according to layer of input map'''
- vdb = Module('v.db.connect', map=map, flags='g', stdout_=PIPE)
+ vdb = Module('v.db.connect', map=mapp, flags='g', stdout_=PIPE)
vdb = vdb.outputs.stdout
for line in vdb.splitlines():
@@ -353,8 +356,6 @@
:param list timeseries: a list of timeseries
"""
- # idKye = 'linkid' #TODO
-
mode = None
unit = None
cats = None
@@ -363,7 +364,7 @@
cats = self.cats.GetValue().split(',')
if cats and self.poi:
GMessage(message=_("Both coordinates and categories are set, "
- "coordinates will be used. The use categories"
+ "coordinates will be used. The use categories "
"remove text from coordinate form"))
if not attribute or attribute == '':
GError(parent=self, showTraceback=False,
@@ -434,6 +435,7 @@
wherequery = ''
totcat = len(cats)
ncat = 1
+ categories = self._getCategories(row[0]['name'])
for cat in cats:
if ncat == 1 and totcat != 1:
wherequery += '{k}={c} or'.format(c=cat, k="{key}")
@@ -450,7 +452,7 @@
ncat += 1
for row in rows:
lay = int(row['layer'])
- catkey = self.parseVDbConn(row['name'], lay)
+ catkey = self._parseVDbConn(row['name'], lay)
if not catkey:
GError(parent=self, showTraceback=False,
message=_("No connection between vector map {vmap} "
More information about the grass-commit
mailing list