[GRASS-SVN] r33223 - in grass/trunk/gui/wxpython: gui_modules icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 2 11:04:26 EDT 2008
Author: martinl
Date: 2008-09-02 11:04:26 -0400 (Tue, 02 Sep 2008)
New Revision: 33223
Modified:
grass/trunk/gui/wxpython/gui_modules/dbm.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/icons/icon.py
Log:
wxGUI: various vector map query tool oriented fixes
(merge from devbr6, r33222)
Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-09-02 15:03:10 UTC (rev 33222)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-09-02 15:04:26 UTC (rev 33223)
@@ -1124,8 +1124,11 @@
columnName.append(list.GetColumn(i).GetText())
# maximal category number
- maxCat = max(list.itemCatsMap.values())
-
+ if len(list.itemCatsMap.values()) > 0:
+ maxCat = max(list.itemCatsMap.values())
+ else:
+ maxCat = 0 # starting category '1'
+
# key column must be always presented
if keyColumn not in columnName:
columnName.insert(0, keyColumn) # insert key column on first position
@@ -1197,7 +1200,11 @@
del values[0]
# add new item to the list
- index = max(list.itemIndexMap) + 1
+ if len(list.itemIndexMap) > 0:
+ index = max(list.itemIndexMap) + 1
+ else:
+ index = 0
+
list.itemIndexMap.append(index)
list.itemDataMap[index] = values
list.itemCatsMap[index] = cat
@@ -2108,7 +2115,7 @@
'key': (wx.StaticText(parent=self.addPanel, id=wx.ID_ANY,
label='%s:' % _("Key column")),
wx.TextCtrl(parent=self.addPanel, id=wx.ID_ANY,
- value='',
+ value='cat',
style=wx.TE_PROCESS_ENTER))}
# events
self.tableWidgets['table'][1].Bind(wx.EVT_TEXT_ENTER, self.OnCreateTable)
@@ -2496,6 +2503,13 @@
"Table name or key column name is missing."),
caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
return
+
+ if table in self.addLayerWidgets['table'][1].GetItems():
+ wx.MessageBox(parent=self,
+ message=_("Unable to create new table. "
+ "Table <%s> already exists in the database.") % table,
+ caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ return
# create table
sql = 'CREATE TABLE %s (%s INTEGER)' % (table, key)
@@ -2950,81 +2964,85 @@
self.mapDBInfo.tables[table][name]['values'].append(None)
else: # change status 'add' -> 'update'
self.action = "update"
-
- # use scrolled panel instead (and fix initial max height of the window to 480px)
- ### panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY)
- 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 " % (_("Layer"), layer))
-
- # notebook body
- border = wx.BoxSizer(wx.VERTICAL)
-
table = self.mapDBInfo.layers[layer]["table"]
key = self.mapDBInfo.layers[layer]["key"]
columns = self.mapDBInfo.tables[table]
# value
- if len(columns[key]['values']) == 0: # no cats
- sizer = wx.BoxSizer(wx.VERTICAL)
- txt = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("No database record available."))
- sizer.Add(txt, proportion=1,
- flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER | wx.EXPAND)
- border.Add(item=sizer, proportion=1,
- flag=wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER,
- border=10)
- panel.SetSizer(border)
- continue
+ # if len(columns[key]['values']) == 0: # no cats
+ # self.notebook.AddPage(page=panel, text=" %s %d / %s %d" % (_("Layer"), layer,
+ # _("Category"), cat))
+
+ # sizer = wx.BoxSizer(wx.VERTICAL)
+ # txt = wx.StaticText(parent=panel, id=wx.ID_ANY,
+ # label=_("No database record available."))
+ # sizer.Add(txt, proportion=1,
+ # flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER | wx.EXPAND)
+ # border.Add(item=sizer, proportion=1,
+ # flag=wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER,
+ # border=10)
+ # panel.SetSizer(border)
+ # continue
+
for idx in range(len(columns[key]['values'])):
+ for name in columns.keys():
+ if name == key:
+ cat = int(columns[name]['values'][idx])
+ 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)
+
+ 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.AddGrowableCol(3)
- # columns
+ # columns (sorted by index)
+ names = [''] * len(columns.keys())
for name in columns.keys():
+ names[columns[name]['index']] = name
+
+ for name in names:
+ if name == key: # skip key column (category)
+ continue
+
vtype = columns[name]['type']
if columns[name]['values'][idx] is not None:
value = str(columns[name]['values'][idx])
else:
value = ''
-
- if name == key:
- box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
- label=" %s %s " % (_("Category"), value))
- boxFont = self.GetFont()
- boxFont.SetWeight(wx.FONTWEIGHT_BOLD)
- box.SetFont(boxFont)
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- colValue = box
- else:
- 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) # TODO: validator
- colValue.SetName(name)
- self.Bind(wx.EVT_TEXT, self.OnSQLStatement, colValue)
-
- 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)
+
+ 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) # TODO: validator
+ colValue.SetName(name)
+ self.Bind(wx.EVT_TEXT, self.OnSQLStatement, colValue)
+
+ 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
- sizer.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
- border.Add(item=sizer, 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
-
- panel.SetSizer(border)
# for each layer END
self.Layout()
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-09-02 15:03:10 UTC (rev 33222)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-09-02 15:04:26 UTC (rev 33223)
@@ -1353,7 +1353,10 @@
elif self.mouse["use"] == "queryVector":
# editable mode for vector map layers
- self.parent.QueryVector(self.mouse['begin'][0],self.mouse['begin'][1])
+ self.parent.QueryVector(self.mouse['begin'][0], self.mouse['begin'][1])
+
+ # clear temp canvas
+ self.UpdateMap(render=False, renderVector=False)
elif self.mouse["use"] in ["measure", "profile"]:
# measure or profile
@@ -3269,7 +3272,8 @@
self.toolbars['map'].action['desc'] = 'modifyAttrb'
self.MapWindow.mouse['use'] = "queryVector"
- self.MapWindow.mouse['box'] = "point"
+ self.MapWindow.mouse['box'] = "box"
+ self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
self.MapWindow.zoomtype = 0
# change the cursor
@@ -3422,7 +3426,7 @@
toolsmenu = wx.Menu()
# Add items to the menu
display = wx.MenuItem(parentMenu=toolsmenu, id=wx.ID_ANY,
- text=Icons["queryDisplay"].GetLabel(),
+ text=_("Query raster/vector map(s) (display mode)"),
kind=wx.ITEM_CHECK)
toolsmenu.AppendItem(display)
self.Bind(wx.EVT_MENU, self.OnQueryDisplay, display)
@@ -3430,7 +3434,7 @@
display.Check(True)
modify = wx.MenuItem(parentMenu=toolsmenu, id=wx.ID_ANY,
- text=Icons["queryModify"].GetLabel(),
+ text=_("Query vector map (edit mode)"),
kind=wx.ITEM_CHECK)
toolsmenu.AppendItem(modify)
self.Bind(wx.EVT_MENU, self.OnQueryModify, modify)
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-09-02 15:03:10 UTC (rev 33222)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-09-02 15:04:26 UTC (rev 33223)
@@ -192,8 +192,8 @@
(self.pointer, "pointer", Icons["pointer"].GetBitmap(),
wx.ITEM_CHECK, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(),
self.mapdisplay.OnPointer),
- (self.query, "queryDisplay", Icons["queryDisplay"].GetBitmap(),
- wx.ITEM_CHECK, Icons["queryDisplay"].GetLabel(), Icons["queryDisplay"].GetDesc(),
+ (self.query, "query", Icons["query"].GetBitmap(),
+ wx.ITEM_CHECK, Icons["query"].GetLabel(), Icons["query"].GetDesc(),
self.mapdisplay.OnQuery),
(self.pan, "pan", Icons["pan"].GetBitmap(),
wx.ITEM_CHECK, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py 2008-09-02 15:03:10 UTC (rev 33222)
+++ grass/trunk/gui/wxpython/icons/icon.py 2008-09-02 15:04:26 UTC (rev 33223)
@@ -242,12 +242,9 @@
"pan" : MetaIcon (img=icons_img["pan"],
label=_("Pan"),
desc=_("Drag with mouse to pan")),
- "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")),
+ "query" : MetaIcon (img=icons_img["query"],
+ label=_("Query raster/vector map(s)"),
+ desc=_("Query selected raster/vector map(s)")),
"zoom_back" : MetaIcon (img=icons_img["zoom_back"],
label=_("Return to previous zoom")),
"zoommenu" : MetaIcon (img=icons_img["zoommenu"],
More information about the grass-commit
mailing list