[GRASS-SVN] r30745 - in grass/trunk/gui/wxpython: gui_modules icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 26 14:35:04 EDT 2008
Author: martinl
Date: 2008-03-26 14:35:03 -0400 (Wed, 26 Mar 2008)
New Revision: 30745
Modified:
grass/trunk/gui/wxpython/gui_modules/dbm.py
grass/trunk/gui/wxpython/gui_modules/digit.py
grass/trunk/gui/wxpython/gui_modules/globalvar.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/utils.py
grass/trunk/gui/wxpython/icons/icon.py
Log:
wxGUI: querying vector map layers improved (editable mode added)
Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -970,7 +970,7 @@
# list.lastTurnSelectedCats[:] != list.selectedCats[:]:
# add map layer with higlighted vector features
- self.AddQueryMapLayer(self.map)
+ self.AddQueryMapLayer()
self.mapdisplay.MapWindow.UpdateMap(render=True)
event.Skip()
@@ -1590,35 +1590,6 @@
event.Skip()
- def AddQueryMapLayer(self, map):
- """Redraw a map
-
- Return True if map has been redrawn, False if no map is given
- """
- if self.qlayer:
- map.DeleteLayer(self.qlayer)
-
- list = self.FindWindowById(self.layerPage[self.layer]['data'])
- cats = list.GetSelectedItems()
-
- color = UserSettings.Get(group='atm', key='highlight', subkey='color')
- colorStr = str(color[0]) + ":" + \
- str(color[1]) + ":" + \
- str(color[2]) + ":"
- cmd = ["d.vect",
- "map=%s" % self.vectmap,
- "color=%s" % colorStr,
- "fcolor=%s" % colorStr,
- "cats=%s" % utils.ListOfCatsToRange(cats),
- "width=%d" % UserSettings.Get(group='atm', key='highlight', subkey='width')]
- if self.icon:
- cmd.append("icon=%s" % (self.icon))
- if self.pointsize:
- cmd.append("size=%s" % (self.pointsize))
-
- self.qlayer = map.AddLayer(type='vector', name=globalvar.QUERYLAYER, command=cmd,
- l_active=True, l_hidden=True, l_opacity=1.0)
-
def OnExtractSelected(self, event):
"""
Extract vector objects selected in attribute browse window
@@ -1657,6 +1628,19 @@
return True
return False
+
+ def AddQueryMapLayer(self):
+ """Redraw a map
+
+ Return True if map has been redrawn, False if no map is given
+ """
+ if self.qlayer:
+ self.mapdisplay.Map.DeleteLayer(self.qlayer)
+
+ list = self.FindWindowById(self.layerPage[self.layer]['data'])
+ cats = list.GetSelectedItems() # FIXME: category can be hiden in list
+
+ self.qlayer = self.mapdisplay.AddTmpVectorMapLayer(self.vectmap, cats)
def UpdateDialog(self, layer):
"""Updates dialog layout for given layer"""
@@ -2795,9 +2779,12 @@
def OnCancel(self, event):
"""Cancel button pressed"""
- self.parent.parent.digittoolbar.attributesDialog = None
- self.parent.parent.digit.driver.SetSelected([])
- self.parent.UpdateMap(render=False)
+ self.parent.parent.attributesDialog = None
+ if self.parent.parent.digit:
+ self.parent.parent.digit.driver.SetSelected([])
+ self.parent.UpdateMap(render=False)
+ else:
+ self.parent.parent.OnRender(None)
self.Close()
@@ -2817,7 +2804,7 @@
self.OnCancel(event)
def GetLine(self):
- """Get id of selected line or 'None' if no line is selected"""
+ """Get id of selected vector object or 'None' if nothing selected"""
return self.line
def UpdateDialog(self, query=None, cats=None, line=None):
Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -2160,7 +2160,7 @@
def OnCancel(self, event):
"""Cancel button pressed"""
- self.parent.parent.digittoolbar.categoryDialog = None
+ self.parent.parent.categoryDialog = None
self.parent.parent.digit.driver.SetSelected([])
self.parent.UpdateMap(render=False)
self.Close()
Modified: grass/trunk/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/globalvar.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/gui_modules/globalvar.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -70,7 +70,7 @@
EXT_BIN = ''
EXT_SCT = ''
-def __getGRASSCmds(bin=True, scripts=True, gui_scripts=True):
+def GetGRASSCmds(bin=True, scripts=True, gui_scripts=True):
"""
Create list of all available GRASS commands to use when
parsing string from the command line
@@ -94,8 +94,8 @@
"""@brief Collected GRASS-relared binaries/scripts"""
grassCmd = {}
-grassCmd['all'] = __getGRASSCmds()
-grassCmd['script'] = __getGRASSCmds(bin=False)
+grassCmd['all'] = GetGRASSCmds()
+grassCmd['script'] = GetGRASSCmds(bin=False)
"""@Toolbar icon size"""
toolbarSize = (24, 24)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -143,7 +143,7 @@
self.parent = parent
self.Map = Map
self.tree = tree
- self.gismanager=gismgr
+ self.gismanager = gismgr
#
# Flags
@@ -210,6 +210,7 @@
self.zoomtype = 1 # 1 zoom in, 0 no zoom, -1 zoom out
self.hitradius = 10 # distance for selecting map decorations
+ self.dialogOffset = 5 # offset for dialog (e.g. DisplayAttributesDialog)
# OnSize called to make sure the buffer is initialized.
# This might result in OnSize getting called twice on some
@@ -924,10 +925,9 @@
return
# calculate position of 'update record' dialog
- offset = 5
position = self.mouse['begin']
- posWindow = self.ClientToScreen((position[0] + offset,
- position[1] + offset))
+ posWindow = self.ClientToScreen((position[0] + self.dialogOffset,
+ position[1] + self.dialogOffset))
if digitToolbar.action not in ["moveVertex", "addVertex",
"removeVertex", "editLine"]:
@@ -1002,24 +1002,24 @@
coords = (east, north)
if digitToolbar.action == "displayAttrs":
# select attributes based on coordinates (all layers)
- if digitToolbar.attributesDialog is None:
+ if self.parent.attributesDialog is None:
if digitClass.type == 'vedit':
- digitToolbar.attributesDialog = dbm.DisplayAttributesDialog(parent=self, map=map,
- query=(coords, qdist),
- pos=posWindow,
- action="update")
+ self.parent.attributesDialog = dbm.DisplayAttributesDialog(parent=self, map=map,
+ query=(coords, qdist),
+ pos=posWindow,
+ action="update")
else:
if digitClass.driver.SelectLineByPoint(coords,
digitClass.GetSelectType()) is not None:
- digitToolbar.attributesDialog = dbm.DisplayAttributesDialog(parent=self, map=map,
- cats=digitClass.GetLineCats(),
- line=digitClass.driver.GetSelected()[0],
- action="update")
+ self.parent.attributesDialog = dbm.DisplayAttributesDialog(parent=self, map=map,
+ cats=digitClass.GetLineCats(),
+ line=digitClass.driver.GetSelected()[0],
+ action="update")
else:
# update currently open dialog
if digitClass.type == 'vedit':
- digitToolbar.attributesDialog.UpdateDialog(query=(coords, qdist))
+ self.parent.attributesDialog.UpdateDialog(query=(coords, qdist))
else:
# unselect
digitClass.driver.SetSelected([])
@@ -1030,43 +1030,43 @@
else:
line = digitClass.driver.GetSelected()[0]
# upgrade dialog
- digitToolbar.attributesDialog.UpdateDialog(cats=digitClass.GetLineCats(),
- line=line)
+ self.parent.attributesDialog.UpdateDialog(cats=digitClass.GetLineCats(),
+ line=line)
- line = digitToolbar.attributesDialog.GetLine()
- if digitToolbar.attributesDialog.mapDBInfo and line:
+ line = self.parent.attributesDialog.GetLine()
+ if self.parent.attributesDialog.mapDBInfo and line:
# highlight feature & re-draw map
digitClass.driver.SetSelected([line])
- if not digitToolbar.attributesDialog.IsShown():
- digitToolbar.attributesDialog.Show()
+ if not self.parent.attributesDialog.IsShown():
+ self.parent.attributesDialog.Show()
else:
digitClass.driver.SetSelected([])
- if digitToolbar.attributesDialog.IsShown():
- digitToolbar.attributesDialog.Hide()
+ if self.parent.attributesDialog.IsShown():
+ self.parent.attributesDialog.Hide()
else: # displayCats
- if digitToolbar.categoryDialog is None:
+ if self.parent.categoryDialog is None:
# open new dialog
if digitClass.type == 'vedit':
- digitToolbar.categoryDialog = DigitCategoryDialog(parent=self,
- map=map,
- query=(coords, qdist),
- pos=posWindow,
- title=_("Update categories"))
+ self.parent.categoryDialog = DigitCategoryDialog(parent=self,
+ map=map,
+ query=(coords, qdist),
+ pos=posWindow,
+ title=_("Update categories"))
else:
if digitClass.driver.SelectLineByPoint(coords,
digitClass.GetSelectType()) is not None:
- digitToolbar.categoryDialog = DigitCategoryDialog(parent=self,
- map=map,
- cats=digitClass.GetLineCats(),
- line=digitClass.driver.GetSelected()[0],
- pos=posWindow,
- title=_("Update categories"))
+ self.parent.categoryDialog = DigitCategoryDialog(parent=self,
+ map=map,
+ cats=digitClass.GetLineCats(),
+ line=digitClass.driver.GetSelected()[0],
+ pos=posWindow,
+ title=_("Update categories"))
else:
# update currently open dialog
if digitClass.type == 'vedit':
- digitToolbar.categoryDialog.UpdateDialog(query=(coords, qdist))
+ self.parent.categoryDialog.UpdateDialog(query=(coords, qdist))
else:
# unselect
digitClass.driver.SetSelected([])
@@ -1077,19 +1077,19 @@
else:
line = digitClass.driver.GetSelected()[0]
# upgrade dialog
- digitToolbar.categoryDialog.UpdateDialog(cats=digitClass.GetLineCats(),
+ self.parent.categoryDialog.UpdateDialog(cats=digitClass.GetLineCats(),
line=line)
- line = digitToolbar.categoryDialog.GetLine()
+ line = self.parent.categoryDialog.GetLine()
if line:
# highlight feature & re-draw map
digitClass.driver.SetSelected([line])
- if not digitToolbar.categoryDialog.IsShown():
- digitToolbar.categoryDialog.Show()
+ if not self.parent.categoryDialog.IsShown():
+ self.parent.categoryDialog.Show()
else:
digitClass.driver.SetSelected([])
- if digitToolbar.categoryDialog.IsShown():
- digitToolbar.categoryDialog.Hide()
+ if self.parent.categoryDialog.IsShown():
+ self.parent.categoryDialog.Hide()
self.UpdateMap(render=False)
@@ -1169,6 +1169,10 @@
# querying
self.parent.QueryMap(self.mouse['begin'][0],self.mouse['begin'][1])
+ elif self.mouse["use"] == "queryVector":
+ # editable mode for vector map layers
+ self.parent.QueryVector(self.mouse['begin'][0],self.mouse['begin'][1])
+
elif self.mouse["use"] in ["measure", "profile"]:
# measure or profile
if self.mouse["use"] == "measure":
@@ -1522,9 +1526,8 @@
# add new record into atribute table
if UserSettings.Get(group='vdigit', key="addRecord", subkey='enabled') is True:
- offset = 5
- posWindow = self.ClientToScreen((position[0] + offset,
- position[1] + offset))
+ posWindow = self.ClientToScreen((position[0] + self.dialogOffset,
+ position[1] + self.dialogOffset))
# select attributes based on layer and category
cats = {}
@@ -2298,6 +2301,12 @@
self.Map.region['e'],
self.Map.region['w'])
+ #
+ # Re-use dialogs
+ #
+ self.attributesDialog = None # vector attributes
+ self.categoryDialog = None # vector category
+
def AddToolbar(self, name):
"""
Add defined toolbar to the window
@@ -2765,9 +2774,9 @@
"""
return self.Map
- def OnQuery(self, event):
+ def OnQueryDisplay(self, event):
"""
- Query currrent or last map
+ Query currrent raster/vector map layers (display mode)
"""
# switch GIS Manager to output console to show query results
self.gismanager.notebook.SetSelection(1)
@@ -2775,11 +2784,21 @@
self.MapWindow.mouse['use'] = "query"
self.MapWindow.mouse['box'] = "point"
self.MapWindow.zoomtype = 0
- # event.Skip()
# change the cursor
self.MapWindow.SetCursor(self.cursors["cross"])
+ def OnQueryModify(self, event):
+ """
+ Query vector map layer (edit mode)
+ """
+ self.MapWindow.mouse['use'] = "queryVector"
+ self.MapWindow.mouse['box'] = "point"
+ self.MapWindow.zoomtype = 0
+
+ # change the cursor
+ self.MapWindow.SetCursor(self.cursors["cross"])
+
def QueryMap(self, x, y):
"""
Query map layer features
@@ -2841,6 +2860,116 @@
if vcmd:
gcmd.Command(vcmd)
+ def QueryVector(self, x, y):
+ """
+ Query vector map layer features
+
+ Attribute data of selected vector object are displayed in GUI dialog.
+ Data can be modified (On Submit)
+ """
+ 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=_("Message"),
+ 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)
+ east, north = self.MapWindow.Pixel2Cell((x, y))
+
+ mapName = self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name
+
+ if self.attributesDialog is None:
+ self.attributesDialog = dbm.DisplayAttributesDialog(parent=self.MapWindow,
+ map=mapName,
+ query=((east, north), qdist),
+ pos=posWindow,
+ action="update")
+ else:
+ # update currently open dialog
+ self.attributesDialog.UpdateDialog(query=((east, north), qdist))
+
+ line = self.attributesDialog.GetLine()
+ try:
+ qlayer = self.Map.GetListOfLayers(l_name=globalvar.QUERYLAYER)[0]
+ except IndexError:
+ qlayer = None
+
+ if self.attributesDialog.mapDBInfo and line:
+ # highlight feature & re-draw map
+ if qlayer:
+ qlayer.cmdlist = self.AddTmpVectorMapLayer(mapName, line,
+ useId=True,
+ addLayer=False)
+ else:
+ self.AddTmpVectorMapLayer(mapName, line, useId=True)
+ self.MapWindow.UpdateMap(render=True)
+ # digitClass.driver.SetSelected([line])
+ if not self.attributesDialog.IsShown():
+ self.attributesDialog.Show()
+ else:
+ if qlayer:
+ self.Map.DeleteLayer(qlayer)
+ self.MapWindow.UpdateMap(render=True)
+ if self.attributesDialog.IsShown():
+ self.attributesDialog.Hide()
+
+ def OnQuery(self, event):
+ """Query tools menu"""
+ point = wx.GetMousePosition()
+ toolsmenu = wx.Menu()
+ # Add items to the menu
+ display = wx.MenuItem(toolsmenu, wx.ID_ANY, Icons["queryDisplay"].GetLabel())
+ toolsmenu.AppendItem(display)
+ self.Bind(wx.EVT_MENU, self.OnQueryDisplay, display)
+
+ modify = wx.MenuItem(toolsmenu, wx.ID_ANY, Icons["queryModify"].GetLabel())
+ toolsmenu.AppendItem(modify)
+ self.Bind(wx.EVT_MENU, self.OnQueryModify, modify)
+
+ self.PopupMenu(toolsmenu)
+ toolsmenu.Destroy()
+
+ def AddTmpVectorMapLayer(self, name, cats, useId=False, addLayer=True):
+ """
+ Add temporal vector map layer to map composition
+
+ @param name name of map layer
+ @param useId use feature id instead of category
+ """
+ color = UserSettings.Get(group='atm', key='highlight', subkey='color')
+ colorStr = str(color[0]) + ":" + \
+ str(color[1]) + ":" + \
+ str(color[2]) + ":"
+
+ cmd = ["d.vect",
+ "map=%s" % name,
+ "color=%s" % colorStr,
+ "fcolor=%s" % colorStr,
+ "width=%d" % UserSettings.Get(group='atm', key='highlight', subkey='width')]
+
+ if useId:
+ cmd.append('-i')
+ cmd.append('cats=%s' % str(cats))
+ else:
+ cmd.append("cats=%s" % utils.ListOfCatsToRange(cats))
+
+ # if self.icon:
+ # cmd.append("icon=%s" % (self.icon))
+ # if self.pointsize:
+ # cmd.append("size=%s" % (self.pointsize))
+
+ if addLayer:
+ return self.Map.AddLayer(type='vector', name=globalvar.QUERYLAYER, command=cmd,
+ l_active=True, l_hidden=True, l_opacity=1.0)
+ else:
+ return cmd
+
def OnAnalyze(self, event):
"""
Analysis tools menu
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -103,7 +103,7 @@
self.displaymap = self.rendermap = self.erase = \
self.pointer = self.query = self.pan = self.zoomin = self.zoomout = \
- self.zoomback = self.zoommenu = self.analyze = self.dec = self.savefile = self.printmap =None
+ self.zoomback = self.zoommenu = self.analyze = self.dec = self.savefile = self.printmap = None
# tool, label, bitmap, kind, shortHelp, longHelp, handler
return (
@@ -120,8 +120,8 @@
(self.pointer, "pointer", Icons["pointer"].GetBitmap(),
wx.ITEM_RADIO, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(),
self.mapdisplay.OnPointer),
- (self.query, "query", Icons["query"].GetBitmap(),
- wx.ITEM_RADIO, Icons["query"].GetLabel(), Icons["query"].GetDesc(),
+ (self.query, "queryDisplay", Icons["queryDisplay"].GetBitmap(),
+ wx.ITEM_RADIO, Icons["queryDisplay"].GetLabel(), Icons["queryDisplay"].GetDesc(),
self.mapdisplay.OnQuery),
(self.pan, "pan", Icons["pan"].GetBitmap(),
wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -18,6 +18,7 @@
import sys
import globalvar
+import gcmd
try:
import subprocess
except:
@@ -132,7 +133,6 @@
@return ([available mapsets], [accessible mapsets])
"""
- import gcmd
all_mapsets = []
accessible_mapsets = []
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2008-03-26 15:34:29 UTC (rev 30744)
+++ grass/trunk/gui/wxpython/icons/icon.py 2008-03-26 18:35:03 UTC (rev 30745)
@@ -226,8 +226,10 @@
desc="Drag or click mouse to unzoom"),
"pan" : MetaIcon (img=icons_img["pan"], label="Pan",
desc="Drag with mouse to pan"),
- "query" : MetaIcon (img=icons_img["query"], label="Query",
- desc="Query selected map"),
+ "queryDisplay" : MetaIcon (img=icons_img["query"], label="Query raster/vector map(s) (display mode)",
+ desc="Query selected raster/vector map(s)"),
+ "queryModify" : MetaIcon (img=icons_img["query"], label="Query vector map (editable mode)",
+ desc="Query selected vector map in editable mode"),
"zoom_back" : MetaIcon (img=icons_img["zoom_back"], label="Return to previous zoom"),
"zoommenu" : MetaIcon (img=icons_img["zoommenu"], label="Zoom options",
desc="Display zoom management"),
More information about the grass-commit
mailing list