[GRASS-SVN] r47511 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 9 14:07:37 EDT 2011
Author: annakrat
Date: 2011-08-09 11:07:37 -0700 (Tue, 09 Aug 2011)
New Revision: 47511
Modified:
grass/trunk/gui/wxpython/gui_modules/colorrules.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
grass/trunk/gui/wxpython/gui_modules/wxnviz.py
Log:
wxNviz: thematic mapping for lines
Modified: grass/trunk/gui/wxpython/gui_modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/colorrules.py 2011-08-09 17:16:13 UTC (rev 47510)
+++ grass/trunk/gui/wxpython/gui_modules/colorrules.py 2011-08-09 18:07:37 UTC (rev 47511)
@@ -75,9 +75,16 @@
if self.mapType == 'vector' and self.columnType == 'color':
self.label = wx.StaticText(parent, id = wx.ID_ANY, label = _("Set color for attribute values:"))
elif self.mapType == 'vector' and self.columnType == 'size':
- self.label = wx.StaticText(parent, id = wx.ID_ANY, label = _("Set size for attribute values:"))
+ if self.parent.vectorType == 'points':
+ label = label = _("Set size for attribute values:")
+ else:
+ label = label = _("Set width for attribute values:")
+ self.label = wx.StaticText(parent, id = wx.ID_ANY, label = label)
+
+ # determines how many rules should be added
self.numRules = wx.SpinCtrl(parent, id = wx.ID_ANY,
min = 1, max = 1e6)
+ # add rules
self.btnAdd = wx.Button(parent, id = wx.ID_ADD)
self.btnAdd.Bind(wx.EVT_BUTTON, self.OnAddRules)
@@ -212,7 +219,11 @@
def SetVectorRule(self, num, vals):
"""!Set vector rule"""
tc = self.mainPanel.FindWindowById(num)
- if self.properties['source_rgb'] == '' or self.properties['rgb'] == '':
+ if self.columnType == 'color':
+ source, target = 'source_rgb', 'rgb'
+ else:
+ source, target = 'source_size', 'size'
+ if self.properties[source] == '' or self.properties[target] == '':
tc.SetValue('')
gcmd.GMessage(parent = self,
message = _("Please select attribute column "
@@ -1097,6 +1108,9 @@
self.preview.EraseMap()
return
+ busy = wx.BusyInfo(message = _("Please wait, loading data from attribute table..."),
+ parent = self)
+ wx.Yield()
if self.inmap:
outFile = tempfile.NamedTemporaryFile(mode='w+b')
sep = '|'
@@ -1111,6 +1125,7 @@
else:
self.OnPreview(event)
+ busy.Destroy()
return
if type == 'color':
ctype = self.dbInfo.GetTableDesc(self.properties['table'])\
@@ -1150,6 +1165,8 @@
else:
rulesPanel.Clear()
+ busy.Destroy()
+
def SetRangeLabel(self, type, ctype, minim, maxim):
"""!Set labels with info about attribute column range"""
if type == 'color':
@@ -1237,9 +1254,10 @@
## return False
class ThematicVectorTable(VectorColorTable):
- def __init__(self, parent, **kwargs):
+ def __init__(self, parent, vectorType, **kwargs):
"""!Dialog for interactively entering color/size rules
for vector maps for thematic mapping in nviz"""
+ self.vectorType = vectorType
VectorColorTable.__init__(self, parent = parent, **kwargs)
# additional bingings
@@ -1251,6 +1269,7 @@
self.SetTitle(_("Thematic mapping for vector map in 3D view"))
+
def UpdateDialog(self):
"""!Update dialog according to selected map"""
VectorColorTable.UpdateDialog(self)
@@ -1410,7 +1429,12 @@
"""!Create part of dialog with layer/column selection"""
layer_label = wx.StaticText(parent, id = wx.ID_ANY, label = _('Layer:'))
self.rgb_check = wx.CheckBox(parent, id = wx.ID_ANY, label = _('Use color for thematic mapping:'))
- self.size_check = wx.CheckBox(parent, id = wx.ID_ANY, label = _('Use size for thematic mapping:'))
+ if self.vectorType == 'points':
+ label = _('Use symbol size for thematic mapping:')
+ else:
+ label = _('Use line width for thematic mapping:')
+ self.size_check = wx.CheckBox(parent, id = wx.ID_ANY, label = label)
+
self.rgb_check.SetValue(True)
self.size_check.SetValue(True)
@@ -1420,8 +1444,12 @@
label = _('Attribute column:'))
rgb_col_label = wx.StaticText(parent, id = wx.ID_ANY,
label = _('RGB color column:'))
- size_col_label = wx.StaticText(parent, id = wx.ID_ANY,
- label = _('Size column:'))
+ if self.vectorType == 'points':
+ label = _('Symbol size column:')
+ else:
+ label = _('Line with column:')
+ size_col_label = wx.StaticText(parent, id = wx.ID_ANY, label = label)
+
self.rgb_range_label = wx.StaticText(parent, id = wx.ID_ANY)
self.size_range_label = wx.StaticText(parent, id = wx.ID_ANY)
cb_size = (150, -1)
@@ -1435,8 +1463,13 @@
self.btn_add_size = wx.Button(parent, id = wx.ID_ANY,
label = _('Add column'))
self.btn_add_RGB.SetToolTipString(_("Add GRASSRGB column to current attribute table."))
- self.btn_add_size.SetToolTipString(_("Add size column to current attribute table."))
+ if self.vectorType == 'points':
+ label = _("Add size column to current attribute table.")
+ else:
+ label = _("Add width column to current attribute table.")
+ self.btn_add_size.SetToolTipString(label)
+
# layout
inputBox = wx.StaticBox(parent = parent, id = wx.ID_ANY,
label = " %s " % _("Select vector columns"))
@@ -1490,7 +1523,11 @@
def OnAddSizeColumn(self, event):
"""!Add size column if it doesn't exist"""
- name = 'GRASSSIZE'
+ if self.vectorType == 'points':
+ name = 'GRASSSIZE'
+ else:
+ name = 'GRASSWIDTH'
+
ret = gcmd.RunCommand('v.db.addcolumn',
map = self.inmap,
layer = self.properties['layer'],
@@ -1526,8 +1563,13 @@
'-a',
'map=%s' % self.inmap,
'type=point,line,boundary,area']
+
if self.size_check.IsChecked() and self.properties["size"]:
- cmdlist.append('size_column=%s' % self.properties["size"])
+ if self.vectorType == 'points':
+ cmdlist.append('size_column=%s' % self.properties["size"])
+ else:
+ cmdlist.append('width_column=%s' % self.properties["size"])
+
if self.rgb_check.IsChecked() and self.properties["rgb"]:
cmdlist.append('rgb_column=%s' % self.properties["rgb"])
ltype = 'vector'
@@ -1544,17 +1586,18 @@
data = self.parent.GetLayerData(nvizType = 'vector')
data['vector']['points']['thematic']['layer'] = int(self.properties['layer'])
+
if self.size_check.IsChecked() and self.properties['size']:
- data['vector']['points']['thematic']['sizecolumn'] = self.properties['size']
+ data['vector'][self.vectorType]['thematic']['sizecolumn'] = self.properties['size']
else:
- data['vector']['points']['thematic']['sizecolumn'] = None
+ data['vector'][self.vectorType]['thematic']['sizecolumn'] = None
if self.rgb_check.IsChecked() and self.properties['rgb']:
- data['vector']['points']['thematic']['rgbcolumn'] = self.properties['rgb']
+ data['vector'][self.vectorType]['thematic']['rgbcolumn'] = self.properties['rgb']
else:
- data['vector']['points']['thematic']['rgbcolumn'] = None
+ data['vector'][self.vectorType]['thematic']['rgbcolumn'] = None
- data['vector']['points']['thematic']['update'] = None
+ data['vector'][self.vectorType]['thematic']['update'] = None
event = wxUpdateProperties(data = data)
wx.PostEvent(self.parent.mapWindow, event)
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-09 17:16:13 UTC (rev 47510)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-09 18:07:37 UTC (rev 47511)
@@ -1540,7 +1540,16 @@
self._display.SetVectorLineHeight(id,
data['height']['value'])
data['height'].pop('update')
-
+
+ # thematic
+ if 'update' in data['thematic']:
+ if data['thematic']['use']:
+ self._display.SetLinesStyleThematic(id = id, layer = data['thematic']['layer'],
+ color = data['thematic']['rgbcolumn'],
+ width = data['thematic']['sizecolumn'])
+ else:
+ self._display.UnsetLinesStyleThematic(id = id)
+ data['thematic'].pop('update')
# surface
if 'surface' in data['mode'] and 'update' in data['mode']:
for item in range(len(data['mode']['surface']['value'])):
@@ -1590,11 +1599,11 @@
# thematic
if 'update' in data['thematic']:
if data['thematic']['use']:
- self._display.SetStyleThematic(id = id, layer = data['thematic']['layer'],
+ self._display.SetPointsStyleThematic(id = id, layer = data['thematic']['layer'],
color = data['thematic']['rgbcolumn'],
size = data['thematic']['sizecolumn'])
else:
- self._display.UnsetStyleThematic(id = id)
+ self._display.UnsetPointsStyleThematic(id = id)
data['thematic'].pop('update')
# surface
@@ -1890,7 +1899,7 @@
subcmd += "height=%d " % (self.iview['height']['value'])
subcmd += "perspective=%d " % (self.view['persp']['value'])
subcmd += "twist=%d " % (self.view['twist']['value'])
- subcmd += "zexag=%d " % (self.view['z-exag']['value'])
+ subcmd += "zexag=%d " % (self.view['z-exag']['value'] * self.iview['z-exag']['original'])
subcmd += "focus=%d,%d,%d " % (self.iview['focus']['x'],self.iview['focus']['y'],self.iview['focus']['z'])
cmd += subcmd
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-09 17:16:13 UTC (rev 47510)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-09 18:07:37 UTC (rev 47511)
@@ -1145,10 +1145,33 @@
gridSizer.Add(item = color, pos = (0, 4), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_LEFT)
+ # thematic mapping
+ self.win['vector']['lines']['thematic'] = {}
+ checkThematic = wx.CheckBox(parent = panel, id = wx.ID_ANY,
+ label = _("use thematic mapping for vector lines"))
+ self.win['vector']['lines']['thematic']['check'] = checkThematic.GetId()
+ checkThematic.Bind(wx.EVT_CHECKBOX, self.OnCheckThematic)
+ checkThematic.SetValue(False)
+
+ hSizer = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer.Add(item = checkThematic, flag = wx.ALIGN_CENTER_VERTICAL,
+ border = 5)
+
+ setThematic = wx.Button(parent = panel, id = wx.ID_ANY,
+ label = _("Set options..."))
+ self.win['vector']['lines']['thematic']['button'] = setThematic.GetId()
+ setThematic.Bind(wx.EVT_BUTTON, self.OnSetThematic)
+ hSizer.Add(item = wx.Size(-1, -1), proportion = 1)
+ hSizer.Add(item = setThematic, flag = wx.ALIGN_CENTER_VERTICAL|wx.LEFT,
+ border = 5, proportion = 0)
+
+ gridSizer.Add(item = hSizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
+ pos = (1, 1), span = (1, 5))
+
# display
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Display")),
- pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL |
+ pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL |
wx.ALIGN_LEFT)
display = wx.Choice (parent = panel, id = wx.ID_ANY, size = (-1, -1),
@@ -1158,12 +1181,12 @@
display.Bind(wx.EVT_CHOICE, self.OnVectorDisplay)
gridSizer.Add(item = display, flag = wx.ALIGN_CENTER_VERTICAL |
- wx.ALIGN_LEFT|wx.EXPAND, pos = (1, 1), span = (1,4))
+ wx.ALIGN_LEFT|wx.EXPAND, pos = (2, 1), span = (1,4))
# height
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Height above surface:")),
- pos = (2, 5), flag = wx.ALIGN_BOTTOM|wx.EXPAND)
+ pos = (3, 5), flag = wx.ALIGN_BOTTOM|wx.EXPAND)
surface = wx.CheckListBox(parent = panel, id = wx.ID_ANY, size = (-1, 60),
choices = [], style = wx.LB_NEEDED_SB)
@@ -1171,7 +1194,7 @@
self.win['vector']['lines']['surface'] = surface.GetId()
gridSizer.Add(item = surface,
- pos = (2, 0), span = (3, 5),
+ pos = (3, 0), span = (3, 5),
flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self._createControl(panel, data = self.win['vector']['lines'], name = 'height', size = -1,
@@ -1180,9 +1203,9 @@
self.FindWindowById(self.win['vector']['lines']['height']['slider']).SetValue(0)
self.FindWindowById(self.win['vector']['lines']['height']['text']).SetValue(0)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['lines']['height']['slider']),
- pos = (3, 5), flag = wx.EXPAND|wx.ALIGN_RIGHT)
+ pos = (4, 5), flag = wx.EXPAND|wx.ALIGN_RIGHT)
gridSizer.Add(item = self.FindWindowById(self.win['vector']['lines']['height']['text']),
- pos = (4, 5),
+ pos = (5, 5),
flag = wx.ALIGN_CENTER)
boxSizer.Add(item = gridSizer, proportion = 1,
@@ -3186,18 +3209,29 @@
def OnCheckThematic(self, event):
"""!Switch on/off thematic mapping"""
- check = self.win['vector']['points']['thematic']['check']
- button = self.win['vector']['points']['thematic']['button']
- if self.FindWindowById(check).GetValue():
- checked = True
+ # can be called with no event to enable/disable button
+ if not event:
+ ids = (self.win['vector']['points']['thematic']['check'],
+ self.win['vector']['lines']['thematic']['check'])
else:
- checked = False
- self.FindWindowById(button).Enable(checked)
+ ids = (event.GetId(),)
+ for id in ids:
+ if id == self.win['vector']['points']['thematic']['check']:
+ type = 'points'
+ else:
+ type = 'lines'
+ check = self.win['vector'][type]['thematic']['check']
+ button = self.win['vector'][type]['thematic']['button']
+ if self.FindWindowById(check).GetValue():
+ checked = True
+ else:
+ checked = False
+ self.FindWindowById(button).Enable(checked)
+
+ data = self.GetLayerData('vector')
+ data['vector'][type]['thematic']['use'] = checked
+ data['vector'][type]['thematic']['update'] = None
- data = self.GetLayerData('vector')
- data['vector']['points']['thematic']['use'] = checked
- data['vector']['points']['thematic']['update'] = None
-
# update properties
event = wxUpdateProperties(data = data)
wx.PostEvent(self.mapWindow, event)
@@ -3207,7 +3241,11 @@
def OnSetThematic(self, event):
"""!Set options for thematic points"""
- ctable = colorrules.ThematicVectorTable(self)
+ if event.GetId() == self.win['vector']['points']['thematic']['button']:
+ vectorType = 'points'
+ else:
+ vectorType = 'lines'
+ ctable = colorrules.ThematicVectorTable(self, vectorType)
ctable.CentreOnScreen()
ctable.Show()
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-08-09 17:16:13 UTC (rev 47510)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-08-09 18:07:37 UTC (rev 47511)
@@ -525,6 +525,8 @@
'color' : (0, 0, 255, 255), # blue
'flat' : False,
'height' : 0,
+ 'rgbcolumn': None,
+ 'sizecolumn': None,
},
'points' : {
'show' : False,
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-08-09 17:16:13 UTC (rev 47510)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-08-09 18:07:37 UTC (rev 47511)
@@ -705,7 +705,13 @@
# height
data['height'] = { 'value' : UserSettings.Get(group='nviz', key='vector',
subkey=['lines', 'height']) }
-
+ # thematic
+ data['thematic'] = {'rgbcolumn' : UserSettings.Get(group='nviz', key='vector',
+ subkey=['lines', 'rgbcolumn']),
+ 'sizecolumn' : UserSettings.Get(group='nviz', key='vector',
+ subkey=['lines', 'sizecolumn']),
+ 'layer': 1,
+ 'use' : False}
if 'object' in data:
for attrb in ('color', 'width', 'mode', 'height'):
data[attrb]['update'] = None
Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-08-09 17:16:13 UTC (rev 47510)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-08-09 18:07:37 UTC (rev 47511)
@@ -940,13 +940,21 @@
return 1
- def SetStyleThematic(self, id, layer, color = None, width = None, size = None, symbol = None):
+ def SetPointStyleThematic(self, id, layer, color = None, width = None, size = None, symbol = None):
"""!Set thematic style for vector points"""
GP_set_style_thematic(id, layer, color, width, size, symbol)
+
+ def SetLinesStyleThematic(self, id, layer, color = None, width = None):
+ """!Set thematic style for vector lines"""
+ GV_set_style_thematic(id, layer, color, width)
- def UnsetStyleThematic(self, id):
+ def UnsetLinesStyleThematic(self, id):
"""!Unset thematic style for vector points"""
- GP_unset_style_thematic(id)
+ GP_unset_style_thematic(id)
+
+ def UnsetPointStyleThematic(self, id):
+ """!Unset thematic style for vector lines"""
+ GV_unset_style_thematic(id)
def UnsetVectorPointSurface(self, id, surf_id):
"""!Unset reference surface of vector set (points)
More information about the grass-commit
mailing list