[GRASS-SVN] r47173 - in
grass/branches/releasebranch_6_4/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 18 15:54:42 EDT 2011
Author: martinl
Date: 2011-07-18 12:54:42 -0700 (Mon, 18 Jul 2011)
New Revision: 47173
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_base.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_dialogs.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py
grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
Log:
wxGUI: fix and simplify raster/vector querying in 2D
(merge r47170 & r41171 from devbr6)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_base.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_base.py 2011-07-18 19:54:07 UTC (rev 47172)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_base.py 2011-07-18 19:54:42 UTC (rev 47173)
@@ -6,7 +6,7 @@
List of classes:
- VectorDBInfo
-(C) 2007-2010 by the GRASS Development Team
+(C) 2007-2011 by the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
@@ -28,6 +28,9 @@
def unicodeValue(value):
"""!Encode value"""
+ if type(value) == types.UnicodeType:
+ return value
+
enc = UserSettings.Get(group = 'atm', key = 'encoding', subkey = 'value')
if enc:
value = unicode(value, enc)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_dialogs.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_dialogs.py 2011-07-18 19:54:07 UTC (rev 47172)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/dbm_dialogs.py 2011-07-18 19:54:42 UTC (rev 47173)
@@ -29,10 +29,10 @@
class DisplayAttributesDialog(wx.Dialog):
def __init__(self, parent, map,
- query=None, cats=None, line=None,
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
- pos=wx.DefaultPosition,
- action="add"):
+ query = None, cats = None, line = None,
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
+ pos = wx.DefaultPosition,
+ action = "add"):
"""!Standard dialog used to add/update/display attributes linked
to the vector map.
@@ -67,39 +67,41 @@
label = _("Database connection "
"is not defined in DB file.")
- wx.MessageBox(parent=self.parent,
- message=_("No attribute table linked to "
+ wx.MessageBox(parent = self.parent,
+ message = _("No attribute table linked to "
"vector map <%(vector)s> found. %(msg)s"
"\nYou can disable this message from digitization settings. Or "
"you can create and link attribute table to the vector map "
"using Attribute Table Manager.") %
{'vector' : self.map, 'msg' : label},
- caption=_("Message"), style=wx.OK | wx.ICON_EXCLAMATION | wx.CENTRE)
+ caption = _("Message"), style = wx.OK | wx.ICON_EXCLAMATION | wx.CENTRE)
self.mapDBInfo = None
- wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY,
- title="", style=style, pos=pos)
+ wx.Dialog.__init__(self, parent = self.parent, id = wx.ID_ANY,
+ title = "", style = style, pos = pos)
# dialog body
mainSizer = wx.BoxSizer(wx.VERTICAL)
# notebook
- self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
+ self.notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
- self.closeDialog = wx.CheckBox(parent=self, id=wx.ID_ANY,
- label=_("Close dialog on submit"))
+ self.closeDialog = wx.CheckBox(parent = self, id = wx.ID_ANY,
+ label = _("Close dialog on submit"))
self.closeDialog.SetValue(True)
-
+ if self.action == 'display':
+ self.closeDialog.Enable(False)
+
# feature id (text/choice for duplicates)
- self.fidMulti = wx.Choice(parent=self, id=wx.ID_ANY,
- size=(150, -1))
+ self.fidMulti = wx.Choice(parent = self, id = wx.ID_ANY,
+ size = (150, -1))
self.fidMulti.Bind(wx.EVT_CHOICE, self.OnFeature)
- self.fidText = wx.StaticText(parent=self, id=wx.ID_ANY)
+ self.fidText = wx.StaticText(parent = self, id = wx.ID_ANY)
- self.noFoundMsg = wx.StaticText(parent=self, id=wx.ID_ANY,
- label=_("No attributes found"))
+ self.noFoundMsg = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _("No attributes found"))
- self.UpdateDialog(query=query, cats=cats)
+ self.UpdateDialog(query = query, cats = cats)
# set title
if self.action == "update":
@@ -113,7 +115,9 @@
btnCancel = wx.Button(self, wx.ID_CANCEL)
btnReset = wx.Button(self, wx.ID_UNDO, _("&Reload"))
btnSubmit = wx.Button(self, wx.ID_OK, _("&Submit"))
-
+ if self.action == 'display':
+ btnSubmit.Enable(False)
+
btnSizer = wx.StdDialogButtonSizer()
btnSizer.AddButton(btnCancel)
btnSizer.AddButton(btnReset)
@@ -122,25 +126,25 @@
btnSizer.AddButton(btnSubmit)
btnSizer.Realize()
- mainSizer.Add(item=self.noFoundMsg, proportion=0,
- flag=wx.EXPAND | wx.ALL, border=5)
- mainSizer.Add(item=self.notebook, proportion=1,
- flag=wx.EXPAND | wx.ALL, border=5)
+ mainSizer.Add(item = self.noFoundMsg, proportion = 0,
+ flag = wx.EXPAND | wx.ALL, border = 5)
+ mainSizer.Add(item = self.notebook, proportion = 1,
+ flag = wx.EXPAND | wx.ALL, border = 5)
fidSizer = wx.BoxSizer(wx.HORIZONTAL)
- fidSizer.Add(item=wx.StaticText(parent=self, id=wx.ID_ANY,
- label=_("Feature id:")),
- proportion=0, border=5,
- flag=wx.ALIGN_CENTER_VERTICAL)
- fidSizer.Add(item=self.fidMulti, proportion=0,
- flag=wx.EXPAND | wx.ALL, border=5)
- fidSizer.Add(item=self.fidText, proportion=0,
- flag=wx.EXPAND | wx.ALL, border=5)
- mainSizer.Add(item=fidSizer, proportion=0,
- flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5)
- mainSizer.Add(item=self.closeDialog, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
- border=5)
- mainSizer.Add(item=btnSizer, proportion=0,
- flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
+ fidSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
+ label = _("Feature id:")),
+ proportion = 0, border = 5,
+ flag = wx.ALIGN_CENTER_VERTICAL)
+ fidSizer.Add(item = self.fidMulti, proportion = 0,
+ flag = wx.EXPAND | wx.ALL, border = 5)
+ fidSizer.Add(item = self.fidText, proportion = 0,
+ flag = wx.EXPAND | wx.ALL, border = 5)
+ mainSizer.Add(item = fidSizer, proportion = 0,
+ flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 5)
+ mainSizer.Add(item = self.closeDialog, proportion = 0, flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
+ border = 5)
+ mainSizer.Add(item = btnSizer, proportion = 0,
+ flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
# bindigs
btnReset.Bind(wx.EVT_BUTTON, self.OnReset)
@@ -160,7 +164,7 @@
if self.notebook.GetPageCount() == 0:
Debug.msg(2, "DisplayAttributesDialog(): Nothing found!")
### self.mapDBInfo = None
-
+
def __SelectAttributes(self, layer):
"""!Select attributes"""
pass
@@ -169,7 +173,15 @@
"""!Update SQL statement"""
pass
- def GetSQLString(self, updateValues=False):
+ def IsFound(self):
+ """!Check for status
+
+ @return True on attributes found
+ @return False attributes not found
+ """
+ return bool(self.notebook.GetPageCount())
+
+ def GetSQLString(self, updateValues = False):
"""!Create SQL statement string based on self.sqlStatement
If updateValues is True, update dataFrame according to values
@@ -267,7 +279,8 @@
"""!Cancel button pressed
"""
self.parent.parent.dialogs['attributes'] = None
- if self.parent.digit:
+
+ if hasattr(self, "digit"):
self.parent.digit.GetDisplay().SetSelected([])
self.parent.UpdateMap(render = False)
else:
@@ -277,8 +290,8 @@
def OnSubmit(self, event):
"""!Submit records"""
- for sql in self.GetSQLString(updateValues=True):
- enc = UserSettings.Get(group='atm', key='encoding', subkey='value')
+ for sql in self.GetSQLString(updateValues = True):
+ enc = UserSettings.Get(group = 'atm', key = 'encoding', subkey = 'value')
if not enc and 'GRASS_DB_ENCODING' in os.environ:
enc = os.environ['GRASS_DB_ENCODING']
if enc:
@@ -293,7 +306,7 @@
def OnFeature(self, event):
self.fid = int(event.GetString())
- self.UpdateDialog(cats=self.cats, fid=self.fid)
+ self.UpdateDialog(cats = self.cats, fid = self.fid)
def GetCats(self):
"""!Get id of selected vector object or 'None' if nothing selected
@@ -309,11 +322,28 @@
"""!Get selected feature id"""
return self.fid
- def UpdateDialog(self, map=None, query=None, cats=None, fid=-1):
+ def UpdateDialog(self, map = None, query = None, cats = None, fid = -1,
+ action = None):
"""!Update dialog
-
- Return True if updated otherwise False
+
+ @param map name of vector map
+ @param query
+ @param cats
+ @param fid feature id
+ @param action add, update, display or None
+
+ @return True if updated
+ @return False
"""
+ if action:
+ self.action = action
+ if action == 'display':
+ enabled = False
+ else:
+ enabled = True
+ self.closeDialog.Enable(enabled)
+ self.FindWindowById(wx.ID_OK).Enable(enabled)
+
if map:
self.map = map
# get layer/table/column information
@@ -321,11 +351,11 @@
if not self.mapDBInfo:
return False
-
+
self.mapDBInfo.Reset()
-
+
layers = self.mapDBInfo.layers.keys() # get available layers
-
+
# id of selected line
if query: # select by position
data = self.mapDBInfo.SelectByPoint(query[0],
@@ -348,7 +378,7 @@
idx += 1
else:
self.cats = cats
-
+
if fid > 0:
self.fid = fid
elif len(self.cats.keys()) > 0:
@@ -374,21 +404,21 @@
# reset notebook
self.notebook.DeleteAllPages()
-
+
for layer in layers: # for each layer
if not query: # select by layer/cat
if self.fid > 0 and layer in self.cats[self.fid]:
for cat in self.cats[self.fid][layer]:
nselected = self.mapDBInfo.SelectFromTable(layer,
- where="%s=%d" % \
+ where = "%s=%d" % \
(self.mapDBInfo.layers[layer]['key'],
cat))
else:
nselected = 0
-
+
# if nselected <= 0 and self.action != "add":
# continue # nothing selected ...
-
+
if self.action == "add":
if nselected <= 0:
if layer in self.cats[self.fid]:
@@ -415,17 +445,17 @@
break
# use scrolled panel instead (and fix initial max height of the window to 480px)
- panel = scrolled.ScrolledPanel(parent=self.notebook, id=wx.ID_ANY,
- size=(-1, 150))
- panel.SetupScrolling(scroll_x=False)
+ panel = scrolled.ScrolledPanel(parent = self.notebook, id = wx.ID_ANY,
+ size = (-1, 150))
+ panel.SetupScrolling(scroll_x = False)
- self.notebook.AddPage(page=panel, text=" %s %d / %s %d" % (_("Layer"), layer,
+ self.notebook.AddPage(page = panel, text = " %s %d / %s %d" % (_("Layer"), layer,
_("Category"), cat))
-
+
# notebook body
border = wx.BoxSizer(wx.VERTICAL)
-
- flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3)
+
+ flexSizer = wx.FlexGridSizer (cols = 4, hgap = 3, vgap = 3)
flexSizer.AddGrowableCol(3)
# columns (sorted by index)
names = [''] * len(columns.keys())
@@ -445,34 +475,35 @@
value = columns[name]['values'][idx]
else:
value = ''
-
- colName = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=name)
- colType = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label="[" + vtype.lower() + "]")
- delimiter = wx.StaticText(parent=panel, id=wx.ID_ANY, label=":")
- colValue = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=value)
+ colName = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = name)
+ colType = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = "[" + vtype.lower() + "]")
+ delimiter = wx.StaticText(parent = panel, id = wx.ID_ANY, label = ":")
+ colValue = wx.TextCtrl(parent = panel, id = wx.ID_ANY, value = value)
colValue.SetName(name)
self.Bind(wx.EVT_TEXT, self.OnSQLStatement, colValue)
+ if self.action == 'display':
+ colValue.SetWindowStyle(wx.TE_READONLY)
- flexSizer.Add(colName, proportion=0,
- flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(colType, proportion=0,
- flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(delimiter, proportion=0,
- flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(colValue, proportion=1,
- flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
+ flexSizer.Add(colName, proportion = 0,
+ flag = wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
+ flexSizer.Add(colType, proportion = 0,
+ flag = wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
+ flexSizer.Add(delimiter, proportion = 0,
+ flag = wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
+ flexSizer.Add(colValue, proportion = 1,
+ flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
# add widget reference to self.columns
columns[name]['ids'].append(colValue.GetId()) # name, type, values, id
# for each attribute (including category) END
- border.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
+ border.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
panel.SetSizer(border)
# for each category END
# for each layer END
-
+
if self.notebook.GetPageCount() == 0:
self.noFoundMsg.Show(True)
else:
@@ -497,8 +528,8 @@
break
class ModifyTableRecord(wx.Dialog):
- def __init__(self, parent, id, title, data, keyEditable=(-1, True),
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
+ def __init__(self, parent, id, title, data, keyEditable = (-1, True),
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
"""!Dialog for inserting/updating table record
Notes:
@@ -507,25 +538,25 @@
is editable(True) or not.
"""
# parent -> VDigitWindow
- wx.Dialog.__init__(self, parent, id, title, style=style)
+ wx.Dialog.__init__(self, parent, id, title, style = style)
self.CenterOnParent()
self.keyId = keyEditable[0]
- self.panel = wx.Panel(parent=self, id=wx.ID_ANY)
+ self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
- box = wx.StaticBox(parent=self.panel, id=wx.ID_ANY, label='')
+ box = wx.StaticBox(parent = self.panel, id = wx.ID_ANY, label = '')
- self.dataPanel = scrolled.ScrolledPanel(parent=self.panel, id=wx.ID_ANY,
- style=wx.TAB_TRAVERSAL)
- self.dataPanel.SetupScrolling(scroll_x=False)
+ self.dataPanel = scrolled.ScrolledPanel(parent = self.panel, id = wx.ID_ANY,
+ style = wx.TAB_TRAVERSAL)
+ self.dataPanel.SetupScrolling(scroll_x = False)
#
# buttons
#
self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)
- self.btnSubmit = wx.Button(self.panel, wx.ID_OK, _("Submit"))
+ self.btnSubmit = wx.Button(self.panel, wx.ID_OK, _("&Submit"))
self.btnSubmit.SetDefault()
#
@@ -545,14 +576,14 @@
id += 1
continue
else:
- valueWin = wx.SpinCtrl(parent=self.dataPanel, id=wx.ID_ANY,
- value=value, min=-1e9, max=1e9, size=(250, -1))
+ valueWin = wx.SpinCtrl(parent = self.dataPanel, id = wx.ID_ANY,
+ value = value, min = -1e9, max = 1e9, size = (250, -1))
else:
- valueWin = wx.TextCtrl(parent=self.dataPanel, id=wx.ID_ANY,
- value=value, size=(250, -1))
+ valueWin = wx.TextCtrl(parent = self.dataPanel, id = wx.ID_ANY,
+ value = value, size = (250, -1))
- label = wx.StaticText(parent=self.dataPanel, id=wx.ID_ANY,
- label=column + ":")
+ label = wx.StaticText(parent = self.dataPanel, id = wx.ID_ANY,
+ label = column + ":")
self.widgets.append((label.GetId(),
valueWin.GetId()))
@@ -560,38 +591,31 @@
id += 1
self.__Layout()
-
- # winSize = self.GetSize()
- # fix height of window frame if needed
- # if winSize[1] > 480:
- # winSize[1] = 480
- # self.SetSize(winSize)
- # self.SetMinSize(winSize)
-
+
def __Layout(self):
"""!Do layout"""
sizer = wx.BoxSizer(wx.VERTICAL)
# data area
- dataSizer = wx.FlexGridSizer (cols=2, hgap=3, vgap=3)
+ dataSizer = wx.FlexGridSizer (cols = 2, hgap = 3, vgap = 3)
dataSizer.AddGrowableCol(1)
for labelId, valueId in self.widgets:
label = self.FindWindowById(labelId)
value = self.FindWindowById(valueId)
- dataSizer.Add(label, proportion=0,
- flag=wx.ALIGN_CENTER_VERTICAL)
- dataSizer.Add(value, proportion=0,
- flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
+ dataSizer.Add(label, proportion = 0,
+ flag = wx.ALIGN_CENTER_VERTICAL)
+ dataSizer.Add(value, proportion = 0,
+ flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
self.dataPanel.SetAutoLayout(True)
self.dataPanel.SetSizer(dataSizer)
dataSizer.Fit(self.dataPanel)
if self.usebox:
- self.boxSizer.Add(item=self.dataPanel, proportion=1,
- flag=wx.EXPAND | wx.ALL, border=5)
+ self.boxSizer.Add(item = self.dataPanel, proportion = 1,
+ flag = wx.EXPAND | wx.ALL, border = 5)
# buttons
btnSizer = wx.StdDialogButtonSizer()
@@ -600,15 +624,15 @@
btnSizer.Realize()
if not self.usebox:
- sizer.Add(item=self.dataPanel, proportion=1,
- flag=wx.EXPAND | wx.ALL, border=5)
+ sizer.Add(item = self.dataPanel, proportion = 1,
+ flag = wx.EXPAND | wx.ALL, border = 5)
else:
- sizer.Add(item=self.boxSizer, proportion=1,
- flag=wx.EXPAND | wx.ALL, border=5)
+ sizer.Add(item = self.boxSizer, proportion = 1,
+ flag = wx.EXPAND | wx.ALL, border = 5)
- sizer.Add(item=btnSizer, proportion=0,
- flag=wx.EXPAND | wx.ALL, border=5)
+ sizer.Add(item = btnSizer, proportion = 0,
+ flag = wx.EXPAND | wx.ALL, border = 5)
framewidth = self.GetSize()[0]
self.SetMinSize((framewidth,150))
@@ -621,27 +645,7 @@
self.Layout()
-# # set window frame size (min & max)
-# minFrameHeight = 150
-# maxFrameHeight = 2 * minFrameHeight
-# if self.GetSize()[1] > minFrameHeight:
-# print 'size ='+str(self.GetSize()[1])
-# print 'if 1'
-# self.SetMinSize((self.GetSize()[0], minFrameHeight))
-# else:
-# print 'else 1'
-# self.SetMinSize(self.GetSize())
-
-# if self.GetSize()[1] > maxFrameHeight:
-# print 'if 2'
-# self.SetSize((self.GetSize()[0], maxFrameHeight))
-# else:
-# print 'else 2'
-# self.SetSize(self.panel.GetSize())
-
-
-
- def GetValues(self, columns=None):
+ def GetValues(self, columns = None):
"""!Return list of values (casted to string).
If columns is given (list), return only values of given columns.
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py 2011-07-18 19:54:07 UTC (rev 47172)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py 2011-07-18 19:54:42 UTC (rev 47173)
@@ -360,12 +360,10 @@
# check for GLCanvas and OpenGL
if not nviz.haveNviz:
self.toolbars['map'].combo.SetValue (_("2D view"))
- wx.MessageBox(parent = self,
- message = _("Unable to switch to 3D display mode.\nThe Nviz python extension "
- "was not found or loaded properly.\n"
- "Switching back to 2D display mode.\n\nDetails: %s" % nviz.errorMsg),
- caption = _("Error"),
- style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ gcmd.GError(parent = self,
+ message = _("Unable to switch to 3D display mode.\nThe Nviz python extension "
+ "was not found or loaded properly.\n"
+ "Switching back to 2D display mode.\n\nDetails: %s" % nviz.errorMsg))
return
# add Nviz toolbar and disable 2D display mode tools
@@ -602,7 +600,7 @@
else: # line, boundary
self.MapWindow.mouse['box'] = 'line'
elif self.toolbars['vdigit'].GetAction() in ['addVertex', 'removeVertex', 'splitLine',
- 'editLine', 'displayCats', 'displayAttrs',
+ 'editLine', 'displayCats', 'queryMap',
'copyCats']:
self.MapWindow.mouse['box'] = 'point'
else: # moveLine, deleteLine
@@ -1216,46 +1214,7 @@
def GetWindow(self):
"""!Get map window"""
return self.MapWindow
-
- def _OnQuery(self):
- """!Internal method used by OnQuery*() methods"""
- if not self.IsStandalone() and \
- self.toolbars['map'].GetAction() == 'displayAttrb':
- # switch to output console to show query results
- self._layerManager.notebook.SetSelectionByName('output')
-
- self.MapWindow.mouse['box'] = "point"
- self.MapWindow.zoomtype = 0
-
- # change the cursor
- self.MapWindow.SetCursor(self.cursors["cross"])
-
- def OnQueryDisplay(self, event):
- """!Query currrent raster/vector map layers (display mode) -
- 2D view mode
- """
- if self.toolbars['map'].GetAction() == 'displayAttrb': # select previous action
- self.toolbars['map'].SelectDefault(event)
- return
-
- self.toolbars['map'].action['desc'] = 'displayAttrb'
-
- self.MapWindow.mouse['use'] = "query"
- self._OnQuery()
-
- def OnQueryModify(self, event):
- """!Query vector map layer (edit mode) - 2D view mode
- """
- if self.toolbars['map'].GetAction() == 'modifyAttrb': # select previous action
- self.toolbars['map'].SelectDefault(event)
- return
-
- self.toolbars['map'].action['desc'] = 'modifyAttrb'
-
- self.MapWindow.mouse['use'] = "queryVector"
- self.MapWindow.pen = wx.Pen(colour = 'Red', width = 2, style = wx.SHORT_DASH)
- self._OnQuery()
-
+
def OnNvizQuerySurface(self, event):
"""!Query current surface in 3D view mode"""
if self.toolbars['map'].GetAction() == 'nvizQuerySurface':
@@ -1312,9 +1271,10 @@
ltype = self.tree.GetPyData(layer)[0]['maplayer'].GetType()
dcmd = self.tree.GetPyData(layer)[0]['cmd']
name, found = utils.GetLayerNameFromCmd(dcmd)
+
if not found:
continue
- if ltype is 'raster':
+ if ltype == 'raster':
rast.append(name)
elif ltype in ('rgb', 'his'):
for iname in name.split('\n'):
@@ -1394,23 +1354,13 @@
"""
if not self.tree.layer_selected or \
self.tree.GetPyData(self.tree.layer_selected)[0]['type'] != 'vector':
- wx.MessageBox(parent = self,
- message = _("No vector map selected for querying."),
- caption = _("Vector querying"),
- style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+ gcmd.GMessage(parent = self,
+ message = _("No vector map selected for querying."))
return
- if self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].GetMapset() != \
- grass.gisenv()['MAPSET']:
- wx.MessageBox(parent = self,
- message = _("Only vector map from the current mapset can be modified."),
- caption = _("Vector querying"),
- style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
- return
-
posWindow = self.ClientToScreen((x + self.MapWindow.dialogOffset,
y + self.MapWindow.dialogOffset))
-
+
qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w']) /
self.Map.width)
@@ -1418,21 +1368,32 @@
mapName = self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name
+ if self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].GetMapset() != \
+ grass.gisenv()['MAPSET']:
+ mode = 'display'
+ else:
+ mode = 'update'
+
if self.dialogs['attributes'] is None:
- self.dialogs['attributes'] = \
- dbm_dialogs.DisplayAttributesDialog(parent = self.MapWindow,
- map = mapName,
- query = ((east, north), qdist),
- pos = posWindow,
- action = "update")
+ dlg = dbm_dialogs.DisplayAttributesDialog(parent = self.MapWindow,
+ map = mapName,
+ query = ((east, north), qdist),
+ pos = posWindow,
+ action = mode)
+ self.dialogs['attributes'] = dlg
+
else:
# selection changed?
if not self.dialogs['attributes'].mapDBInfo or \
self.dialogs['attributes'].mapDBInfo.map != mapName:
- self.dialogs['attributes'].UpdateDialog(map = mapName, query = ((east, north), qdist))
+ self.dialogs['attributes'].UpdateDialog(map = mapName, query = ((east, north), qdist),
+ action = mode)
else:
- self.dialogs['attributes'].UpdateDialog(query = ((east, north), qdist))
-
+ self.dialogs['attributes'].UpdateDialog(query = ((east, north), qdist),
+ action = mode)
+ if not self.dialogs['attributes'].IsFound():
+ self._layerManager.goutput.WriteLog(_('Nothing found.'))
+
cats = self.dialogs['attributes'].GetCats()
try:
@@ -1469,11 +1430,8 @@
self.toolbars['map'].OnTool(event)
action = self.toolbars['map'].GetAction()
- point = wx.GetMousePosition()
- toolsmenu = wx.Menu()
-
- # add items to the menu
if self.toolbars['nviz']:
+ toolsmenu = wx.Menu()
raster = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
text = _("Query surface (raster map)"),
kind = wx.ITEM_CHECK)
@@ -1488,48 +1446,23 @@
self.Bind(wx.EVT_MENU, self.OnNvizQueryVector, vector)
if action == "nvizQueryVector":
vector.Check(True)
+
+ self.PopupMenu(toolsmenu)
+ toolsmenu.Destroy()
else:
- display = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
- text = _("Query raster/vector map(s) (display mode)"),
- kind = wx.ITEM_CHECK)
- toolsmenu.AppendItem(display)
- self.Bind(wx.EVT_MENU, self.OnQueryDisplay, display)
- numLayers = 0
- if self.tree:
- for layer in self.tree.GetSelections():
- ltype = self.tree.GetPyData(layer)[0]['maplayer'].GetType()
- if ltype in ('raster', 'rgb', 'his',
- 'vector', 'thememap', 'themechart'):
- numLayers += 1
- if not self.IsStandalone() and numLayers < 1:
- display.Enable(False)
- if action == "displayAttrb":
- display.Check(True)
+ self.toolbars['map'].action['desc'] = 'queryMap'
+ self.MapWindow.mouse['use'] = "query"
- modify = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
- text = _("Query vector map (edit mode)"),
- kind = wx.ITEM_CHECK)
- toolsmenu.AppendItem(modify)
- self.Bind(wx.EVT_MENU, self.OnQueryModify, modify)
- modify.Enable(False)
- if action == "modifyAttrb":
- modify.Check(True)
+ if not self.IsStandalone():
+ # switch to output console to show query results
+ self._layerManager.notebook.SetSelectionByName('output')
- digitToolbar = self.toolbars['vdigit']
- if self.tree and self.tree.layer_selected:
- mapLayer = self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer']
- if mapLayer.GetType() == 'vector' and \
- mapLayer.GetMapset() == grass.gisenv()['MAPSET'] and \
- (not digitToolbar or (digitToolbar and \
- digitToolbar.GetLayer() != mapLayer)):
- modify.Enable(True)
- else:
- if action == "modifyAttrb":
- modify.Check(True)
+ self.MapWindow.mouse['box'] = "point"
+ self.MapWindow.zoomtype = 0
+
+ # change the cursor
+ self.MapWindow.SetCursor(self.cursors["cross"])
- self.PopupMenu(toolsmenu)
- toolsmenu.Destroy()
-
def AddTmpVectorMapLayer(self, name, cats, useId = False, addLayer = True):
"""!Add temporal vector map layer to map composition
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py 2011-07-18 19:54:07 UTC (rev 47172)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp_window.py 2011-07-18 19:54:42 UTC (rev 47173)
@@ -1191,8 +1191,23 @@
elif self.mouse["use"] == "query":
# querying
- self.parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1])
-
+ layers = self.GetSelectedLayer(multi = True)
+ isRaster = False
+ nVectors = 0
+ for l in layers:
+ if l.GetType() == 'raster':
+ isRaster = True
+ break
+ if l.GetType() == 'vector':
+ nVectors += 1
+
+ if isRaster or nVectors > 1:
+ self.parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1])
+ else:
+ self.parent.QueryVector(self.mouse['begin'][0], self.mouse['begin'][1])
+ # clear temp canvas
+ self.UpdateMap(render = False, renderVector = False)
+
elif self.mouse["use"] == "queryVector":
# editable mode for vector map layers
self.parent.QueryVector(self.mouse['begin'][0], self.mouse['begin'][1])
Modified: grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py 2011-07-18 19:54:07 UTC (rev 47172)
+++ grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py 2011-07-18 19:54:42 UTC (rev 47173)
@@ -893,7 +893,7 @@
if os.path.exists(filename):
dlg = wx.MessageDialog(self, message = _("Workspace file <%s> already exists. "
- "Do you want to overwrite this file?") % filename,
+ "Do you want to overwrite this file?") % filename,
caption = _("Save workspace"), style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() != wx.ID_YES:
dlg.Destroy()
More information about the grass-commit
mailing list