[GRASS-SVN] r46584 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 7 09:40:28 EDT 2011
Author: annakrat
Date: 2011-06-07 06:40:28 -0700 (Tue, 07 Jun 2011)
New Revision: 46584
Modified:
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: changes in view page interface, constant surface resolution added
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-06-07 08:19:03 UTC (rev 46583)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-06-07 13:40:28 UTC (rev 46584)
@@ -250,8 +250,8 @@
size = self.GetClientSize()
self._display.LookHere(pos[0], size[1] - pos[1])
self.DoPaint()
- comboId = self.lmgr.nviz.win['view']['lookAt']
- self.lmgr.nviz.FindWindowById(comboId).SetSelection(0)
+ toggle = self.lmgr.nviz.FindWindowByName('here')
+ toggle.SetValue(False)
self.mouse['use'] = 'default'
self.SetCursor(self.cursors['default'])
@@ -545,14 +545,19 @@
@param id nviz layer id (or -1)
@param nvizType nviz data type (surface, points, vector)
"""
- type = self.tree.GetPyData(item)[0]['maplayer'].type
- # reference to original layer properties (can be None)
- data = self.tree.GetPyData(item)[0]['nviz']
-
+ if nvizType != 'constant':
+ type = self.tree.GetPyData(item)[0]['maplayer'].type
+ # reference to original layer properties (can be None)
+ data = self.tree.GetPyData(item)[0]['nviz']
+ else:
+ type = nvizType
+ data = self.constants[item]
+
if not data:
# init data structure
- self.tree.GetPyData(item)[0]['nviz'] = {}
- data = self.tree.GetPyData(item)[0]['nviz']
+ if nvizType != 'constant':
+ self.tree.GetPyData(item)[0]['nviz'] = {}
+ data = self.tree.GetPyData(item)[0]['nviz']
if type == 'raster':
# reset to default properties
@@ -566,6 +571,9 @@
elif type == '3d-raster':
# reset to default properties
data[nvizType] = self.nvizDefault.SetVolumeDefaultProp()
+
+ elif type == 'constant':
+ data['constant'] = self.nvizDefault.SetConstantDefaultProp()
else:
# complete data (use default values)
@@ -595,6 +603,9 @@
elif type == 'vector':
data['vector'][nvizType]['object'] = { 'id' : id,
'init' : False }
+ elif type == 'constant':
+ data[nvizType]['object'] = { 'id' : id,
+ 'init' : False }
return data
@@ -662,6 +673,30 @@
return id
+ def AddConstant(self):
+ """!Add new constant"""
+ index = len(self.constants)
+ try:
+ name = self.constants[-1]['constant']['object']['name'] + 1
+ except IndexError:
+ name = 1
+ data = dict()
+ self.constants.append(data)
+ data = self.SetMapObjProperties(item = index, id = -1, nvizType = 'constant')
+ id = self._display.AddConstant(value = data['constant']['value'], color = data['constant']['color'])
+ self._display.SetSurfaceRes(id, data['constant']['resolution'], data['constant']['resolution'])
+ data['constant']['object'] = { 'id' : id,
+ 'name': name,
+ 'init' : False }
+
+ return index, name
+
+ def DeleteConstant(self, index):
+ """!Delete constant layer"""
+ id = self.constants[index]['constant']['object']['id']
+ self._display.UnloadSurface(id)
+ del self.constants[index]
+
def UnloadRaster(self, item):
"""!Unload 2d raster map
@@ -862,6 +897,8 @@
self.view['twist']['value'] = UserSettings.Get(group = 'nviz', key = 'view',
subkey = ('twist', 'value'))
+
+ self._display.LookAtCenter()
event = wxUpdateView(zExag = False)
wx.PostEvent(self, event)
@@ -876,6 +913,12 @@
# -> initialized
data['surface']['object']['init'] = True
+ elif 'constant' in data:
+ id = data['constant']['object']['id']
+ self.UpdateConstantProperties(id, data['constant'])
+ # -> initialized
+ data['constant']['object']['init'] = True
+
elif 'volume' in data:
id = data['volume']['object']['id']
self.UpdateVolumeProperties(id, data['volume'])
@@ -889,12 +932,18 @@
self.UpdateVectorProperties(id, data['vector'], type)
# -> initialized
data['vector'][type]['object']['init'] = True
-
+
+ def UpdateConstantProperties(self, id, data):
+ """!Update surface map object properties"""
+ self._display.SetSurfaceColor(id = id, map = False, value = data['color'])
+ self._display.SetSurfaceTopo(id = id, map = False, value = data['value'])
+ self._display.SetSurfaceRes(id, data['resolution'], data['resolution'])
+
def UpdateSurfaceProperties(self, id, data):
"""!Update surface map object properties"""
# surface attributes
for attrb in ('color', 'mask',
- 'transp', 'shine', 'emit'):
+ 'transp', 'shine'):
if attrb not in data['attribute'] or \
'update' not in data['attribute'][attrb]:
continue
@@ -909,9 +958,7 @@
# TODO: broken in NVIZ
self._display.UnsetSurfaceMask(id)
elif attrb == 'transp':
- self._display.UnsetSurfaceTransp(id)
- elif attrb == 'emit':
- self._display.UnsetSurfaceEmit(id)
+ self._display.UnsetSurfaceTransp(id)
else:
if type(value) == type('') and \
len(value) <= 0: # ignore empty values (TODO: warning)
@@ -926,8 +973,6 @@
self._display.SetSurfaceTransp(id, map, str(value))
elif attrb == 'shine':
self._display.SetSurfaceShine(id, map, str(value))
- elif attrb == 'emit':
- self._display.SetSurfaceEmit(id, map, str(value))
data['attribute'][attrb].pop('update')
# draw res
@@ -1076,12 +1121,15 @@
if 'surface' in data['mode']:
if 'update' in data['mode']['surface']:
for item in range(len(data['mode']['surface']['value'])):
- sid = self.GetLayerId(type = 'raster', name = data['mode']['surface']['value'][item])
- if sid > -1:
- if data['mode']['surface']['show'][item]:
- self._display.SetVectorLineSurface(id, sid)
- else:
- self._display.UnsetVectorLineSurface(id, sid)
+ for type in ('raster', 'constant'):
+ sid = self.GetLayerId(type = type,
+ name = data['mode']['surface']['value'][item])
+ if sid > -1:
+ if data['mode']['surface']['show'][item]:
+ self._display.SetVectorLineSurface(id, sid)
+ else:
+ self._display.UnsetVectorLineSurface(id, sid)
+ break
data['mode']['surface'].pop('update')
@@ -1118,32 +1166,46 @@
if 'surface' in data['mode']:
if 'update' in data['mode']['surface']:
for item in range(len(data['mode']['surface']['value'])):
- sid = self.GetLayerId(type = 'raster', name = data['mode']['surface']['value'][item])
- if sid > -1:
- if data['mode']['surface']['show'][item]:
- self._display.SetVectorPointSurface(id, sid)
- else:
- self._display.UnsetVectorPointSurface(id, sid)
+ for type in ('raster', 'constant'):
+ sid = self.GetLayerId(type = type,
+ name = data['mode']['surface']['value'][item])
+ if sid > -1:
+ if data['mode']['surface']['show'][item]:
+ self._display.SetVectorPointSurface(id, sid)
+ else:
+ self._display.UnsetVectorPointSurface(id, sid)
+ break
data['mode']['surface'].pop('update')
def GetLayerNames(self, type):
"""!Return list of map layer names of given type"""
layerName = []
- for item in self.layers:
- mapLayer = self.tree.GetPyData(item)[0]['maplayer']
- if type != mapLayer.GetType():
- continue
-
- layerName.append(mapLayer.GetName())
+ if type == 'constant':
+ for item in self.constants:
+ layerName.append(_("constant#") + str(item['constant']['object']['name']))
+ else:
+ for item in self.layers:
+ mapLayer = self.tree.GetPyData(item)[0]['maplayer']
+ if type != mapLayer.GetType():
+ continue
+
+ layerName.append(mapLayer.GetName())
return layerName
- def GetLayerId(self, type, name):
+ def GetLayerId(self, type, name, vsubtyp = None):
"""!Get layer object id or -1"""
if len(name) < 1:
return -1
+ if type == 'constant':
+ for item in self.constants:
+ if _("constant#") + str(item['constant']['object']['name']) == name:
+ return item['constant']['object']['id']
+
+ return self.constants
+
for item in self.layers:
mapLayer = self.tree.GetPyData(item)[0]['maplayer']
if type != mapLayer.GetType() or \
@@ -1154,13 +1216,13 @@
if type == 'raster':
return data['surface']['object']['id']
- elif type == 'vpoint':
- return data['vector']['points']['object']['id']
- elif type == 'vline':
- return data['vector']['lines']['object']['id']
+ elif type == 'vector':
+ if vsubtyp == 'vpoint':
+ return data['vector']['points']['object']['id']
+ elif vsubtyp == 'vline':
+ return data['vector']['lines']['object']['id']
elif type == '3d-raster':
return data['volume']['object']['id']
-
return -1
def SaveToFile(self, FileName, FileType, width, height):
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-06-07 08:19:03 UTC (rev 46583)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-06-07 13:40:28 UTC (rev 46584)
@@ -58,7 +58,7 @@
class ScrolledPanel(SP.ScrolledPanel):
"""!Custom ScrolledPanel to avoid strange behaviour concerning focus"""
def __init__(self, parent):
- SP.ScrolledPanel.__init__(self, parent = parent, id=wx.ID_ANY)
+ SP.ScrolledPanel.__init__(self, parent = parent, id = wx.ID_ANY)
def OnChildFocus(self, event):
pass
@@ -215,25 +215,42 @@
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("Control View")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 10)
self.win['view'] = {}
# position
posSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
- posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("W")),
- pos = (1, 0), flag = wx.ALIGN_CENTER)
- posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("N")),
- pos = (0, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
+
+ self.win['view']['lookFrom'] = {}
+ w = wx.Button(panel, id = wx.ID_ANY, label = _("W"))
+ n = wx.Button(panel, id = wx.ID_ANY, label = _("N"))
+ s = wx.Button(panel, id = wx.ID_ANY, label = _("S"))
+ e = wx.Button(panel, id = wx.ID_ANY, label = _("E"))
+ nw = wx.Button(panel, id = wx.ID_ANY, label = _("NW"))
+ ne = wx.Button(panel, id = wx.ID_ANY, label = _("NE"))
+ se = wx.Button(panel, id = wx.ID_ANY, label = _("SE"))
+ sw = wx.Button(panel, id = wx.ID_ANY, label = _("SW"))
+ minWidth = sw.GetTextExtent(sw.GetLabel())[0] + 15
+ for win, name in zip((w, n, s, e, nw, ne, se, sw),
+ ('w', 'n', 's', 'e', 'nw', 'ne', 'se', 'sw')):
+ win.SetMinSize((minWidth, -1))
+ win.Bind(wx.EVT_BUTTON, self.OnLookFrom)
+ win.SetName(name)
+ posSizer.Add(item = nw, pos = (0, 0), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = n, pos = (0, 1), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = ne, pos = (0, 2), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = e, pos = (1, 2), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = se, pos = (2, 2), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = s, pos = (2, 1), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = sw, pos = (2, 0), flag = wx.ALIGN_CENTER)
+ posSizer.Add(item = w, pos = (1, 0), flag = wx.ALIGN_CENTER)
+
view = ViewPositionWindow(panel, size = (175, 175),
mapwindow = self.mapWindow)
self.win['view']['position'] = view.GetId()
posSizer.Add(item = view,
pos = (1, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
- posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("S")),
- pos = (2, 1), flag = wx.ALIGN_CENTER | wx.ALIGN_TOP)
- posSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("E")),
- pos = (1, 2), flag = wx.ALIGN_CENTER)
gridSizer.Add(item = posSizer, pos = (0, 0))
# perspective
@@ -244,7 +261,8 @@
gridSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Perspective:")),
pos = (1, 0), flag = wx.ALIGN_CENTER)
- gridSizer.Add(item = self.FindWindowById(self.win['view']['persp']['slider']), pos = (2, 0))
+ gridSizer.Add(item = self.FindWindowById(self.win['view']['persp']['slider']), pos = (2, 0),
+ flag = wx.ALIGN_CENTER)
gridSizer.Add(item = self.FindWindowById(self.win['view']['persp']['text']), pos = (3, 0),
flag = wx.ALIGN_CENTER)
@@ -270,62 +288,54 @@
heightSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
heightSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Height:")),
- pos = (0, 0), flag = wx.ALIGN_LEFT, span = (1, 2))
+ pos = (0, 0), flag = wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, span = (1, 2))
heightSizer.Add(item = self.FindWindowById(self.win['view']['height']['slider']),
flag = wx.ALIGN_RIGHT, pos = (1, 0))
heightSizer.Add(item = self.FindWindowById(self.win['view']['height']['text']),
- flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
- wx.BOTTOM | wx.RIGHT, pos = (1, 1))
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT, pos = (1, 1))
heightSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY, label = _("Z-exag:")),
- pos = (0, 2), flag = wx.ALIGN_LEFT, span = (1, 2))
+ pos = (0, 2), flag = wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, span = (1, 2))
heightSizer.Add(item = self.FindWindowById(self.win['view']['z-exag']['slider']),
flag = wx.ALIGN_RIGHT, pos = (1, 2))
heightSizer.Add(item = self.FindWindowById(self.win['view']['z-exag']['text']),
flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
wx.BOTTOM | wx.RIGHT, pos = (1, 3))
- gridSizer.Add(item = heightSizer, pos = (0, 1), flag = wx.ALIGN_RIGHT)
+ gridSizer.Add(item = heightSizer, pos = (0, 1), flag = wx.ALIGN_CENTER)
# view setup + reset
viewSizer = wx.BoxSizer(wx.HORIZONTAL)
-
viewSizer.Add(item = wx.StaticText(panel, id = wx.ID_ANY,
- label = _("Look at:")),
+ label = _("Look:")),
flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL,
border = 5)
-
- viewType = wx.Choice (parent = panel, id = wx.ID_ANY, size = (125, -1),
- choices = [_(""),
- _("here"),
- _("top"),
- _("north"),
- _("south"),
- _("east"),
- _("west"),
- _("north-west"),
- _("north-east"),
- _("south-east"),
- _("south-west")])
- viewType.SetSelection(0)
- viewType.Bind(wx.EVT_CHOICE, self.OnLookAt)
- self.win['view']['lookAt'] = viewType.GetId()
- viewSizer.Add(item = viewType,
- flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL,
+ here = wx.ToggleButton(panel, id = wx.ID_ANY, label = _("here"))
+ here.Bind(wx.EVT_TOGGLEBUTTON, self.OnLookAt)
+ here.SetName('here')
+ viewSizer.Add(item = here, flag = wx.TOP|wx.BOTTOM|wx.LEFT|wx.ALIGN_CENTER_VERTICAL,
border = 5)
-
- reset = wx.Button(panel, id = wx.ID_ANY, label = _("Reset"))
+
+ center = wx.Button(panel, id = wx.ID_ANY, label = _("center"))
+ center.Bind(wx.EVT_BUTTON, self.OnLookAt)
+ center.SetName('center')
+ viewSizer.Add(item = center, flag = wx.TOP|wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
+ border = 5)
+
+ top = wx.Button(panel, id = wx.ID_ANY, label = _("top"))
+ top.Bind(wx.EVT_BUTTON, self.OnLookAt)
+ top.SetName('top')
+ viewSizer.Add(item = top, flag = wx.TOP|wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
+ border = 5)
+
+ reset = wx.Button(panel, id = wx.ID_ANY, label = _("reset"))
reset.SetToolTipString(_("Reset to default view"))
- # self.win['reset'] = reset.GetId()
reset.Bind(wx.EVT_BUTTON, self.OnResetView)
-
- viewSizer.Add(item = wx.Size(-1, -1), proportion = 1,
- flag = wx.EXPAND)
viewSizer.Add(item = reset, proportion = 0,
- flag = wx.ALL | wx.ALIGN_RIGHT,
+ flag = wx.TOP|wx.BOTTOM|wx.RIGHT| wx.ALIGN_RIGHT,
border = 5)
gridSizer.AddGrowableCol(2)
- gridSizer.Add(item = viewSizer, pos = (4, 0), span = (1, 2),
+ gridSizer.Add(item = viewSizer, pos = (4, 0), span = (1, 3),
flag = wx.EXPAND)
# body
@@ -512,7 +522,7 @@
all.SetToolTipString(_("Use draw settings for all loaded surfaces"))
all.Bind(wx.EVT_BUTTON, self.OnSurfaceModeAll)
gridSizer.Add(item = all, flag = wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
- pos = (4, 4))
+ pos = (3, 4))
# resolution coarse
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
@@ -544,16 +554,14 @@
pos = (3, 2))
# color
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("wire color:")),
- pos = (4, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT)
color = csel.ColourSelect(panel, id = wx.ID_ANY,
size = globalvar.DIALOG_COLOR_SIZE)
color.SetName("colour")
color.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceWireColor)
+ color.SetToolTipString(_("Change wire color"))
self.win['surface']['draw']['wire-color'] = color.GetId()
- gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
- pos = (4, 2))
+ gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT,
+ pos = (3, 3))
# resolution fine
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
@@ -593,8 +601,7 @@
for code, attrb in (('color', _("Color")),
('mask', _("Mask")),
('transp', _("Transparency")),
- ('shine', _("Shininess")),
- ('emit', _("Emission"))):
+ ('shine', _("Shininess"))):
self.win['surface'][code] = {}
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = attrb + ':'),
@@ -633,7 +640,7 @@
else:
value = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = 0)
- if code in ('shine', 'transp', 'emit'):
+ if code in ('shine', 'transp'):
value.SetRange(minVal = 0, maxVal = 255)
else:
value.SetRange(minVal = 0, maxVal = 100)
@@ -749,7 +756,6 @@
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("Constant surface")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
-
horsizer = wx.BoxSizer(wx.HORIZONTAL)
surface = wx.ComboBox(parent = panel, id = wx.ID_ANY,
@@ -773,35 +779,42 @@
boxSizer.Add(item = horsizer, proportion = 0, flag = wx.ALL|wx.EXPAND,
border = 5)
+ gridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
+ # fine resolution
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Fine resolution:")),
+ pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+ resF = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+ initial = 3,
+ min = 1,
+ max = 100)
+ resF.SetName("value")
+ self.win['constant']['resolution'] = resF.GetId()
+ resF.Bind(wx.EVT_SPINCTRL, self.OnSetConstantProp)
+ gridSizer.Add(item = resF, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
# value
- horsizer = wx.BoxSizer(wx.HORIZONTAL)
- horsizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("Value:")),
- flag = wx.ALIGN_CENTER_VERTICAL|wx.RIGHT,
- border = 15)
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Value:")), pos = (1, 0),
+ flag = wx.ALIGN_CENTER_VERTICAL)
value = wx.SpinCtrl(panel, id = wx.ID_ANY,
min = -1e9, max = 1e9,
size = (65, -1))
self.win['constant']['value'] = value.GetId()
- value.Bind(wx.EVT_SPINCTRL, self.OnConstantValue)
- horsizer.Add(item = value, flag = wx.RIGHT, border = 5)
- boxSizer.Add(item = horsizer, proportion = 0, flag = wx.ALL,
- border = 5)
+ value.Bind(wx.EVT_SPINCTRL, self.OnSetConstantProp)
+ gridSizer.Add(item = value, pos = (1, 1))
# color
- horsizer = wx.BoxSizer(wx.HORIZONTAL)
- horsizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("Color:")),
- flag = wx.ALIGN_CENTER_VERTICAL|wx.RIGHT,
- border = 15)
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Color:")), pos = (2, 0),
+ flag = wx.ALIGN_CENTER_VERTICAL)
color = csel.ColourSelect(panel, id = wx.ID_ANY,
colour = (0,0,0),
size = globalvar.DIALOG_COLOR_SIZE)
self.win['constant']['color'] = color.GetId()
- color.Bind(csel.EVT_COLOURSELECT, self.OnConstantColor)
- horsizer.Add(item = color, flag = wx.RIGHT, border = 5)
- boxSizer.Add(item = horsizer, proportion = 0, flag = wx.ALL,
+ color.Bind(csel.EVT_COLOURSELECT, self.OnSetConstantProp)
+ gridSizer.Add(item = color, pos = (2, 1))
+ boxSizer.Add(item = gridSizer, proportion = 0, flag = wx.ALL,
border = 5)
pageSizer.Add(item = boxSizer, proportion = 0,
flag = wx.EXPAND | wx.ALL,
@@ -1545,31 +1558,31 @@
def OnNewConstant(self, event):
"""!Create new surface with constant value"""
#TODO settings
- value = 0
- color = "0:0:0"
- id = self._display.AddConstant(value = value, color = color)
- if id > 1:
- self.constantIndex += 1
- idx = len(self.mapWindow.constants) + 1
- layer = {'id' : id, 'name' : _("constant#") + str(self.constantIndex),
- 'value' : value, 'color' : color}
- self.mapWindow.constants.append(layer)
- win = self.FindWindowById(self.win['constant']['surface'])
- win.Append(layer['name'])
- win.SetStringSelection(layer['name'])
- self.EnablePage(name = 'constant', enabled = True)
- self.OnConstantSelection(None)
-
- self.mapWindow.Refresh(eraseBackground = False)
+ index, name = self.mapWindow.AddConstant()
+ win = self.FindWindowById(self.win['constant']['surface'])
+ name = _("constant#") + str(name)
+ win.Append(name)
+ win.SetStringSelection(name)
+ self.OnConstantSelection(None)
+ self.EnablePage(name = 'constant', enabled = True)
+ self.mapWindow.Refresh(eraseBackground = False)
+
+ # need to update list of surfaces in vector page
+ for vtype in ('points', 'lines'):
+ checklist = self.FindWindowById(self.win['vector'][vtype]['surface'])
+ checklist.Append(name)
+ win = self.FindWindowById(self.win['vector']['map'])
+ win.SetValue(win.GetValue())
+
+
def OnDeleteConstant(self, event):
"""!Delete selected constant surface"""
layerIdx = self.FindWindowById(self.win['constant']['surface']).GetSelection()
if layerIdx == wx.NOT_FOUND:
return
- id = self.mapWindow.constants[layerIdx]['id']
- self._display.UnloadSurface(id)
- del self.mapWindow.constants[layerIdx]
+ name = self.FindWindowById(self.win['constant']['surface']).GetStringSelection()
+ self.mapWindow.DeleteConstant(layerIdx)
win = self.FindWindowById(self.win['constant']['surface'])
win.Delete(layerIdx)
if win.IsEmpty():
@@ -1578,44 +1591,46 @@
else:
win.SetSelection(0)
self.OnConstantSelection(None)
-
- self.mapWindow.Refresh(False)
+
+ # need to update list of surfaces in vector page
+ for vtype in ('points', 'lines'):
+ checklist = self.FindWindowById(self.win['vector'][vtype]['surface'])
+ checklist.Delete(checklist.FindString(name))
+
+ if self.mapDisplay.statusbarWin['render'].IsChecked():
+ self.mapWindow.Refresh(False)
def OnConstantSelection(self, event):
"""!Constant selected"""
layerIdx = self.FindWindowById(self.win['constant']['surface']).GetSelection()
if layerIdx == wx.NOT_FOUND:
return
- color = self._getColorFromString(self.mapWindow.constants[layerIdx]['color'])
- value = self.mapWindow.constants[layerIdx]['value']
+ name = _("constant#") + str(layerIdx + 1)
+ data = self.mapWindow.constants[layerIdx]
+ for attr, value in data['constant'].iteritems():
+ if attr == 'color':
+ value = self._getColorFromString(value)
+ if attr in ('color', 'value', 'resolution'):
+ self.FindWindowById(self.win['constant'][attr]).SetValue(value)
- self.FindWindowById(self.win['constant']['color']).SetValue(color)
- self.FindWindowById(self.win['constant']['value']).SetValue(value)
-
- def OnConstantColor(self, event):
- """!Change color of currently selected constant surface"""
- color = self._getColorString(event.GetValue())
+ def OnSetConstantProp(self, event):
+ """!Change properties (color, value, resolution)
+ of currently selected constant surface"""
layerIdx = self.FindWindowById(self.win['constant']['surface']).GetSelection()
if layerIdx == wx.NOT_FOUND:
return
- id = self.mapWindow.constants[layerIdx]['id']
- self.mapWindow.constants[layerIdx]['color'] = color
- self._display.SetSurfaceColor(id = id, map = False, value = color)
+ data = self.mapWindow.constants[layerIdx]
+ for attr in ('resolution', 'value'):
+ data['constant'][attr] = self.FindWindowById(self.win['constant'][attr]).GetValue()
+ data['constant']['color'] = self._getColorString(
+ self.FindWindowById(self.win['constant']['color']).GetValue())
+
+ # update properties
+ event = wxUpdateProperties(data = data)
+ wx.PostEvent(self.mapWindow, event)
+ if self.mapDisplay.statusbarWin['render'].IsChecked():
+ self.mapWindow.Refresh(False)
- self.mapWindow.Refresh(False)
-
- def OnConstantValue(self, event):
- """!Change value of currently selected constant surface"""
- value = event.GetInt()
- layerIdx = self.FindWindowById(self.win['constant']['surface']).GetSelection()
- if layerIdx == wx.NOT_FOUND:
- return
- id = self.mapWindow.constants[layerIdx]['id']
- self.mapWindow.constants[layerIdx]['value'] = value
- self._display.SetSurfaceTopo(id = id, map = False, value = value)
-
- self.mapWindow.Refresh(False)
-
def OnFringe(self, event):
"""!Show/hide fringe"""
data = self.GetLayerData('fringe')['surface']
@@ -1882,7 +1897,27 @@
self.Update()
event.Skip()
-
+
+ def OnLookAt(self, event):
+ """!Look here/center"""
+ name = self.FindWindowById(event.GetId()).GetName()
+ if name == 'center':
+ self._display.LookAtCenter()
+ self.mapWindow.Refresh(False)
+ elif name == 'top':
+ self.mapWindow.view['position']['x'] = 0.5
+ self.mapWindow.view['position']['y'] = 0.5
+ self.PostViewEvent(zExag = True)
+ self.UpdateSettings()
+ self.mapWindow.Refresh(False)
+ else: # here
+ if self.FindWindowById(event.GetId()).GetValue():
+ self.mapWindow.mouse['use'] = 'lookHere'
+ self.mapWindow.SetCursor(self.mapWindow.cursors["cross"])
+ else:
+ self.mapWindow.mouse['use'] = 'default'
+ self.mapWindow.SetCursor(self.mapWindow.cursors['default'])
+
def OnResetView(self, event):
"""!Reset to default view (view page)"""
self.mapWindow.ResetView()
@@ -1910,49 +1945,39 @@
if self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
- def OnLookAt(self, event):
- """!Look at (view page)"""
- sel = event.GetSelection()
- if sel == 0: # nothing
- pass
- elif sel == 1:
- self.mapWindow.mouse['use'] = 'lookHere'
- self.mapWindow.SetCursor(self.mapWindow.cursors["cross"])
- elif sel == 2: # top
+ def OnLookFrom(self, event):
+ """!Look from (view page)"""
+ buttonName = self.FindWindowById(event.GetId()).GetName()
+ if buttonName == 'n': # north
self.mapWindow.view['position']['x'] = 0.5
- self.mapWindow.view['position']['y'] = 0.5
- elif sel == 3: # north
- self.mapWindow.view['position']['x'] = 0.5
self.mapWindow.view['position']['y'] = 0.0
- elif sel == 4: # south
+ elif buttonName == 's': # south
self.mapWindow.view['position']['x'] = 0.5
self.mapWindow.view['position']['y'] = 1.0
- elif sel == 5: # east
+ elif buttonName == 'e': # east
self.mapWindow.view['position']['x'] = 1.0
self.mapWindow.view['position']['y'] = 0.5
- elif sel == 6: # west
+ elif buttonName =='w': # west
self.mapWindow.view['position']['x'] = 0.0
self.mapWindow.view['position']['y'] = 0.5
- elif sel == 7: # north-west
+ elif buttonName == 'nw': # north-west
self.mapWindow.view['position']['x'] = 0.0
self.mapWindow.view['position']['y'] = 0.0
- elif sel == 8: # north-east
+ elif buttonName == 'ne': # north-east
self.mapWindow.view['position']['x'] = 1.0
self.mapWindow.view['position']['y'] = 0.0
- elif sel == 9: # south-east
+ elif buttonName == 'se': # south-east
self.mapWindow.view['position']['x'] = 1.0
self.mapWindow.view['position']['y'] = 1.0
- elif sel == 10: # south-west
+ elif buttonName == 'sw': # south-west
self.mapWindow.view['position']['x'] = 0.0
self.mapWindow.view['position']['y'] = 1.0
- if sel >= 2:
- self.PostViewEvent(zExag = True)
- self.UpdateSettings()
- self.mapWindow.render['quick'] = False
- self.mapWindow.Refresh(False)
+ self.PostViewEvent(zExag = True)
- self.FindWindowById(event.GetId()).SetSelection(0)
+ self.UpdateSettings()
+ self.mapWindow.render['quick'] = False
+ self.mapWindow.Refresh(False)
def OnMapObjUse(self, event):
@@ -2115,7 +2140,8 @@
if self.mapDisplay.statusbarWin['render'].IsChecked():
self.mapWindow.Refresh(False)
-
+
+
def SetSurfaceResolution(self):
"""!Set draw resolution"""
coarse = self.FindWindowById(self.win['surface']['draw']['res-coarse']).GetValue()
@@ -2136,15 +2162,8 @@
style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
if style == 0: # wire
self.FindWindowById(self.win['surface']['draw']['wire-color']).Enable(True)
-## self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
elif style == 1: # surface
self.FindWindowById(self.win['surface']['draw']['wire-color']).Enable(False)
-## self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
-## else: # both
-## self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
-## self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
-##
-## style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
@@ -2401,7 +2420,7 @@
for attrb in ('width', 'mode'):
data['vector']['lines'][attrb]['update'] = None
data['vector']['lines']['width']['value'] = width
- data['vector']['lines']['mode']['value'] = mode
+ data['vector']['lines']['mode'] = mode
color = self.FindWindowById(self.win['vector']['lines']['color']).GetColour()
@@ -2476,12 +2495,15 @@
else:
vtype = 'points'
checkList = self.FindWindowById(self.win['vector'][vtype]['surface'])
- checked = checkList.IsChecked(event.GetInt())
- surface = checkList.GetString(event.GetInt())
+ checked = []
+ surfaces = []
+ for items in range(checkList.GetCount()):
+ checked.append(checkList.IsChecked(items))
+ surfaces.append(checkList.GetString(items))
data = self.GetLayerData('vector')
- data['vector'][vtype]['mode']['surface'] = { 'value' : (surface,),
- 'show' : (checked,),
+ data['vector'][vtype]['mode']['surface'] = { 'value' : surfaces,
+ 'show' : checked,
'update': None }
# update properties
event = wxUpdateProperties(data = data)
@@ -3026,15 +3048,32 @@
else:
display.SetSelection(0)
if data[vtype]['mode']['type'] == 'surface':
+ if npoints:
+ vsubtyp = 'vpoint'
+ else:
+ vsubtyp = 'vline'
+ vid = self.mapWindow.GetLayerId(type = 'vector', vsubtyp = vsubtyp, name = layer.name)
rasters = self.mapWindow.GetLayerNames('raster')
- surface = self.FindWindowById(self.win['vector'][vtype]['surface'])
- surface.SetItems(rasters)
- if len(rasters) > 0:
- for item in range(len(rasters)):
- try:
- surface.Check(item, data[vtype]['mode']['surface']['show'][item])
+ constants = self.mapWindow.GetLayerNames('constant')
+ surfaces = rasters + constants
+ surfaceWin = self.FindWindowById(self.win['vector'][vtype]['surface'])
+ surfaceWin.SetItems(surfaces)
+ for idx, surface in enumerate(surfaces):
+ if vtype == 'lines':
+ sid = self.mapWindow.GetLayerId(type = 'raster', name = surface)
+ if sid == -1:
+ sid = self.mapWindow.GetLayerId(type = 'constant', name = surface)
+ if vid > -1 and sid > -1:
+ selected = self._display.VectorSurfaceSelected(vid, sid)
+ else:
+ selected = False
+ else: # points
+ try:# TODO fix this mess
+ selected = data[vtype]['mode']['surface']['show'][idx]
except (TypeError, IndexError, KeyError):
- surface.Check(item, True)
+ selected = False
+ surfaceWin.Check(idx, selected)
+
for type in ('slider', 'text'):
win = self.FindWindowById(self.win['vector']['lines']['height'][type])
win.SetValue(data['lines']['height']['value'])
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-06-07 08:19:03 UTC (rev 46583)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-06-07 13:40:28 UTC (rev 46584)
@@ -511,6 +511,11 @@
'z' : 0,
},
},
+ 'constant' : {
+ 'color' : (100, 100, 100, 255),
+ 'value' : 0.0,
+ 'resolution': 6
+ },
'vector' : {
'lines' : {
'show' : False,
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-06-07 08:19:03 UTC (rev 46583)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-06-07 13:40:28 UTC (rev 46584)
@@ -421,6 +421,16 @@
def __init__(self):
"""Default 3D settings"""
pass
+
+ def SetConstantDefaultProp(self):
+ """Set default constant data properties"""
+ data = dict()
+ for key, value in UserSettings.Get(group='nviz', key='constant').iteritems():
+ data[key] = value
+ color = str(data['color'][0]) + ':' + str(data['color'][1]) + ':' + str(data['color'][2])
+ data['color'] = color
+
+ return data
def SetSurfaceDefaultProp(self):
"""Set default surface data properties"""
@@ -433,7 +443,7 @@
#
for attrb in ('shine', ):
data['attribute'][attrb] = {}
- for key, value in UserSettings.Get(group='nviz', key='volume',
+ for key, value in UserSettings.Get(group='nviz', key='surface',
subkey=attrb).iteritems():
data['attribute'][attrb][key] = value
data['attribute'][attrb]['update'] = None
@@ -486,7 +496,7 @@
if control == 'mode':
continue
if control == 'shading':
- sel = UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'shading'])
+ sel = UserSettings.Get(group='nviz', key='volume', subkey=['draw', 'shading'])
value, desc = self.GetDrawMode(shade=sel, string=False)
data['draw']['shading'] = { 'value' : value,
Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-06-07 08:19:03 UTC (rev 46583)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-06-07 13:40:28 UTC (rev 46584)
@@ -146,7 +146,12 @@
Nviz_look_here(x, y)
Debug.msg(3, "Nviz::LookHere(): x=%f, y=%f", x, y)
-
+
+ def LookAtCenter(self):
+ """!Center view at center of displayed surface"""
+ Nviz_set_focus_map(MAP_OBJ_UNDEFINED, -1)
+ Debug.msg(3, "Nviz::LookAtCenter()")
+
def SetZExag(self, z_exag):
"""!Set z-exag value
@@ -359,6 +364,19 @@
return 1
+ def VectorSurfaceSelected(self, vid, sid):
+ """!Check if surface is selected
+
+ @param vid vector id
+ @param sid surface id
+
+ @return True if selected
+ @return False if not selected
+ """
+ selected = GV_surf_is_selected(vid, sid)
+ Debug.msg(1, "Nviz::VectorSurfaceSelected(): vid=%s, sid=%d -> selected=%d", vid, sid, selected)
+ return selected
+
def LoadVolume(self, name, color_name, color_value):
"""!Load 3d raster map (volume)
@@ -492,7 +510,7 @@
return self.SetSurfaceAttr(id, ATT_SHINE, map, value)
def SetSurfaceEmit(self, id, map, value):
- """!Set surface emission
+ """!Set surface emission (currently unused)
@param id surface id
@param map if true use map otherwise constant
@@ -563,7 +581,7 @@
return self.UnsetSurfaceAttr(id, ATT_TRANSP)
def UnsetSurfaceEmit(self, id):
- """!Unset surface emission
+ """!Unset surface emission (currently unused)
@param id surface id
More information about the grass-commit
mailing list