[GRASS-SVN] r47849 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 23 10:15:29 EDT 2011
Author: annakrat
Date: 2011-08-23 07:15:29 -0700 (Tue, 23 Aug 2011)
New Revision: 47849
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_preferences.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/wxgui.py
Log:
wxNviz: fix preferences dialog
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -481,10 +481,6 @@
CloseButton(False).Layer(2).
BestSize((self.toolbars['georect'].GetBestSize())))
- # nviz
- elif name == "nviz":
- self._addToolbarNviz()
-
self._mgr.Update()
def RemoveToolbar (self, name):
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -139,10 +139,9 @@
self.size = (0, 0)
# default values
+ self.nvizDefault = NvizDefault()
self.view = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'view')) # copy
self.iview = UserSettings.Get(group = 'nviz', key = 'view', internal = True)
-
- self.nvizDefault = NvizDefault()
self.light = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'light')) # copy
self.decoration = self.nvizDefault.SetDecorDefaultProp(type = 'arrow')
self.decoration['scalebar'] = []
@@ -1626,7 +1625,7 @@
data['thematic'].pop('update')
# surface
- if 'update' in data['mode']:
+ if 'update' in data['mode'] and 'surface' in data['mode']:
for item in range(len(data['mode']['surface']['value'])):
for type in ('raster', 'constant'):
sid = self.GetLayerId(type = type,
@@ -1687,6 +1686,22 @@
return data['volume']['object']['id']
return -1
+ def ReloadLayersData(self):
+ """!Delete nviz data of all loaded layers and reload them from current settings"""
+ for item in self.layers:
+ type = self.tree.GetPyData(item)[0]['type']
+ layer = self.tree.GetPyData(item)[0]['maplayer']
+ data = self.tree.GetPyData(item)[0]['nviz']
+
+ if type == 'raster':
+ self.nvizDefault.SetSurfaceDefaultProp(data['surface'])
+ if type == 'vector':
+ npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(layer)
+ if npoints > 0:
+ self.nvizDefault.SetVectorPointsDefaultProp(data['vector']['points'])
+ if nlines > 0:
+ self.nvizDefault.SetVectorLinesDefaultProp(data['vector']['lines'])
+
def NvizCmdCommand(self):
"""!Generate command for nviz_cmd according to current state"""
cmd = 'nviz_cmd '
@@ -2004,5 +2019,3 @@
@param textinfo text metadata (text, font, color, rotation)
"""
return self.parent.MapWindow2D.TextBounds(textinfo, relcoords = True)
-
-
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_preferences.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_preferences.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -33,7 +33,6 @@
PreferencesBaseDialog.__init__(self, parent = parent, title = title,
settings = settings)
self.toolWin = self.parent.nviz
- self.win = dict()
# create notebook pages
self._createViewPage(self.notebook)
@@ -43,9 +42,10 @@
self.SetMinSize(self.GetBestSize())
self.SetSize(self.size)
+ self.btnDefault.SetToolTipString(_("Revert settings to default, changes are not applied"))
def _createViewPage(self, notebook):
- """!Create notebook page for general settings"""
+ """!Create notebook page for view settings"""
panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
notebook.AddPage(page = panel,
@@ -53,152 +53,111 @@
pageSizer = wx.BoxSizer(wx.VERTICAL)
- self.win['general'] = {}
- self.win['view'] = {}
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("View")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
-
+ row = 0
# perspective
- self.win['view']['persp'] = {}
pvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'persp')
ipvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'persp', internal = True)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Perspective:")),
- pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(value)")),
- pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ label = _("value:")),
+ pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
pval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = pvals['value'],
min = ipvals['min'],
max = ipvals['max'])
- self.win['view']['persp']['value'] = pval.GetId()
- gridSizer.Add(item = pval, pos = (0, 2),
+ self.winId['nviz:view:persp:value'] = pval.GetId()
+ gridSizer.Add(item = pval, pos = (row, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(step)")),
- pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ label = _("step:")),
+ pos = (row, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
pstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = pvals['step'],
min = ipvals['min'],
max = ipvals['max']-1)
- self.win['view']['persp']['step'] = pstep.GetId()
- gridSizer.Add(item = pstep, pos = (0, 4),
+ self.winId['nviz:view:persp:step'] = pstep.GetId()
+ gridSizer.Add(item = pstep, pos = (row, 4),
flag = wx.ALIGN_CENTER_VERTICAL)
+ row += 1
# position
- self.win['view']['position'] = {}
posvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'position')
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Position:")),
- pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(x)")),
- pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ label = _("x:")),
+ pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = posvals['x'] * 100,
min = 0,
max = 100)
- self.win['view']['position']['x'] = px.GetId()
- gridSizer.Add(item = px, pos = (1, 2),
+ self.winId['nviz:view:position:x'] = px.GetId()
+ gridSizer.Add(item = px, pos = (row, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = "(y)"),
- pos = (1, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ label = "y:"),
+ pos = (row, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = posvals['y'] * 100,
min = 0,
max = 100)
- self.win['view']['position']['y'] = py.GetId()
- gridSizer.Add(item = py, pos = (1, 4),
+ self.winId['nviz:view:position:y'] = py.GetId()
+ gridSizer.Add(item = py, pos = (row, 4),
flag = wx.ALIGN_CENTER_VERTICAL)
+ row += 1
- # height
- self.win['view']['height'] = {}
- hvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'height')
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("Height:")),
- pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(step)")),
- pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ # height is computed dynamically
- hstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
- initial = hvals['step'],
- min = 1,
- max = 1e6)
- self.win['view']['height']['step'] = hstep.GetId()
- gridSizer.Add(item = hstep, pos = (2, 2),
- flag = wx.ALIGN_CENTER_VERTICAL)
-
# twist
- self.win['view']['twist'] = {}
tvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'twist')
itvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'twist', internal = True)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Twist:")),
- pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(value)")),
- pos = (3, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ label = _("value:")),
+ pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
tval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = tvals['value'],
min = itvals['min'],
max = itvals['max'])
- self.win['view']['twist']['value'] = tval.GetId()
- gridSizer.Add(item = tval, pos = (3, 2),
+ self.winId['nviz:view:twist:value'] = tval.GetId()
+ gridSizer.Add(item = tval, pos = (row, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
+ row += 1
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(step)")),
- pos = (3, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
-
- tstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
- initial = tvals['step'],
- min = itvals['min'],
- max = itvals['max']-1)
- self.win['view']['twist']['step'] = tstep.GetId()
- gridSizer.Add(item = tstep, pos = (3, 4),
- flag = wx.ALIGN_CENTER_VERTICAL)
-
# z-exag
- self.win['view']['z-exag'] = {}
zvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'z-exag')
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Z-exag:")),
- pos = (4, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(value)")),
- pos = (4, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
+ label = _("value:")),
+ pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
zval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+ initial = zvals['value'],
min = -1e6,
max = 1e6)
- self.win['view']['z-exag']['value'] = zval.GetId()
- gridSizer.Add(item = zval, pos = (4, 2),
+ self.winId['nviz:view:z-exag:value'] = zval.GetId()
+ gridSizer.Add(item = zval, pos = (row, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(step)")),
- pos = (4, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
- zstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
- initial = zvals['step'],
- min = -1e6,
- max = 1e6)
- self.win['view']['z-exag']['step'] = zstep.GetId()
- gridSizer.Add(item = zstep, pos = (4, 4),
- flag = wx.ALIGN_CENTER_VERTICAL)
-
boxSizer.Add(item = gridSizer, proportion = 1,
flag = wx.ALL | wx.EXPAND, border = 3)
pageSizer.Add(item = boxSizer, proportion = 0,
@@ -212,7 +171,6 @@
gridSizer.AddGrowableCol(0)
# background color
- self.win['view']['background'] = {}
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Background color:")),
pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
@@ -221,22 +179,22 @@
colour = UserSettings.Get(group = 'nviz', key = 'view',
subkey = ['background', 'color']),
size = globalvar.DIALOG_COLOR_SIZE)
- color.SetName("color")
- self.win['view']['background']['color'] = color.GetId()
+ color.SetName('GetColour')
+ self.winId['nviz:view:background:color'] = color.GetId()
gridSizer.Add(item = color, pos = (0, 1))
boxSizer.Add(item = gridSizer, proportion = 1,
- flag = wx.ALL | wx.EXPAND, border = 3)
+ flag = wx.ALL | wx.EXPAND, border = 5)
pageSizer.Add(item = boxSizer, proportion = 0,
flag = wx.EXPAND | wx.ALL,
- border = 3)
+ border = 5)
panel.SetSizer(pageSizer)
return panel
def _createLightPage(self, notebook):
- """!Create notebook page for general settings"""
+ """!Create notebook page for light settings"""
panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
notebook.AddPage(page = panel,
@@ -244,7 +202,6 @@
pageSizer = wx.BoxSizer(wx.VERTICAL)
- self.win['light'] = {}
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("Light")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
@@ -252,44 +209,43 @@
# position
- self.win['light']['position'] = {}
posvals = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'position')
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Position:")),
pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(x)")),
+ label = _("x:")),
pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = posvals['x'] * 100,
min = -100,
max = 100)
- self.win['light']['position']['x'] = px.GetId()
+ self.winId['nviz:light:position:x'] = px.GetId()
gridSizer.Add(item = px, pos = (0, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = "(y)"),
+ label = "y:"),
pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = posvals['y'] * 100,
min = -100,
max = 100)
- self.win['light']['position']['y'] = py.GetId()
+ self.winId['nviz:light:position:y'] = py.GetId()
gridSizer.Add(item = py, pos = (0, 4),
flag = wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("(z)")),
+ label = _("z:")),
pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
pz = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
initial = posvals['z'],
min = 0,
max = 100)
- self.win['light']['position']['z'] = pz.GetId()
+ self.winId['nviz:light:position:z'] = pz.GetId()
gridSizer.Add(item = pz, pos = (0, 6),
flag = wx.ALIGN_CENTER_VERTICAL)
@@ -303,7 +259,7 @@
initial = brightval,
min = 0,
max = 100)
- self.win['light']['bright'] = bright.GetId()
+ self.winId['nviz:light:bright'] = bright.GetId()
gridSizer.Add(item = bright, pos = (1, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
@@ -317,7 +273,7 @@
initial = ambval,
min = 0,
max = 100)
- self.win['light']['ambient'] = amb.GetId()
+ self.winId['nviz:light:ambient'] = amb.GetId()
gridSizer.Add(item = amb, pos = (2, 2),
flag = wx.ALIGN_CENTER_VERTICAL)
@@ -330,34 +286,32 @@
colour = UserSettings.Get(group = 'nviz', key = 'light',
subkey = 'color'),
size = globalvar.DIALOG_COLOR_SIZE)
- color.SetName("color")
- self.win['light']['color'] = color.GetId()
+ color.SetName('GetColour')
+ self.winId['nviz:light:color'] = color.GetId()
gridSizer.Add(item = color, pos = (3, 2))
boxSizer.Add(item = gridSizer, proportion = 1,
- flag = wx.ALL | wx.EXPAND, border = 3)
+ flag = wx.ALL | wx.EXPAND, border = 5)
pageSizer.Add(item = boxSizer, proportion = 0,
flag = wx.EXPAND | wx.ALL,
- border = 3)
+ border = 5)
panel.SetSizer(pageSizer)
return panel
def _createSurfacePage(self, notebook):
- """!Create notebook page for general settings"""
+ """!Create notebook page for surface settings"""
panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
notebook.AddPage(page = panel,
text = " %s " % _("Surface"))
pageSizer = wx.BoxSizer(wx.VERTICAL)
- self.win['surface'] = {}
# draw
- self.win['surface']['draw'] = {}
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("Draw")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
@@ -371,8 +325,8 @@
choices = [_("coarse"),
_("fine"),
_("both")])
- self.win['surface']['draw']['mode'] = mode.GetId()
- mode.SetName('selection')
+ self.winId['nviz:surface:draw:mode'] = mode.GetId()
+ mode.SetName('GetSelection')
mode.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
subkey = ['draw', 'mode']))
gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
@@ -390,7 +344,7 @@
initial = res,
min = 1,
max = 100)
- self.win['surface']['draw']['res-fine'] = fine.GetId()
+ self.winId['nviz:surface:draw:res-fine'] = fine.GetId()
gridSizer.Add(item = fine, flag = wx.ALIGN_CENTER_VERTICAL,
pos = (1, 2))
@@ -407,7 +361,7 @@
initial = res,
min = 1,
max = 100)
- self.win['surface']['draw']['res-coarse'] = coarse.GetId()
+ self.winId['nviz:surface:draw:res-coarse'] = coarse.GetId()
gridSizer.Add(item = coarse, flag = wx.ALIGN_CENTER_VERTICAL,
pos = (2, 2))
@@ -418,11 +372,11 @@
style = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
choices = [_("wire"),
_("surface")])
- self.win['surface']['draw']['style'] = style.GetId()
- style.SetName('selection')
+ self.winId['nviz:surface:draw:style'] = style.GetId()
+ style.SetName('GetSelection')
style.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
subkey = ['draw', 'style']))
- self.win['surface']['draw']['style'] = style.GetId()
+ self.winId['nviz:surface:draw:style'] = style.GetId()
gridSizer.Add(item = style, flag = wx.ALIGN_CENTER_VERTICAL,
pos = (3, 2))
@@ -434,23 +388,23 @@
colour = UserSettings.Get(group = 'nviz', key = 'surface',
subkey = ['draw', 'wire-color']),
size = globalvar.DIALOG_COLOR_SIZE)
- color.SetName("color")
- self.win['surface']['draw']['wire-color'] = color.GetId()
+ color.SetName('GetColour')
+ self.winId['nviz:surface:draw:wire-color'] = color.GetId()
gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL,
pos = (4, 2))
boxSizer.Add(item = gridSizer, proportion = 1,
- flag = wx.ALL | wx.EXPAND, border = 3)
+ flag = wx.ALL | wx.EXPAND, border = 5)
pageSizer.Add(item = boxSizer, proportion = 0,
flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
- border = 3)
+ border = 5)
panel.SetSizer(pageSizer)
return panel
def _createVectorPage(self, notebook):
- """!Create notebook page for general settings"""
+ """!Create notebook page for vector settings"""
panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
notebook.AddPage(page = panel,
@@ -459,46 +413,53 @@
pageSizer = wx.BoxSizer(wx.VERTICAL)
# vector lines
- self.win['vector'] = {}
- self.win['vector']['lines'] = {}
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("Vector lines")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
- # show
row = 0
- showLines = wx.CheckBox(parent = panel, id = wx.ID_ANY,
- label = _("Show lines"))
- self.win['vector']['lines']['show'] = showLines.GetId()
- showLines.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
- subkey = ['lines', 'show']))
- gridSizer.Add(item = showLines, pos = (row, 0))
+ # icon size
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Width:")),
+ pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+ iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
+ initial = 12,
+ min = 1,
+ max = 100)
+ self.winId['nviz:vector:lines:width'] = iwidth.GetId()
+ iwidth.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
+ subkey = ['lines', 'width']))
+ gridSizer.Add(item = iwidth, pos = (row, 1),
+ flag = wx.ALIGN_CENTER_VERTICAL)
+
+ # icon color
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Color:")),
+ pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
+ icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
+ size = globalvar.DIALOG_COLOR_SIZE)
+ icolor.SetName('GetColour')
+ self.winId['nviz:vector:lines:color'] = icolor.GetId()
+ icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
+ subkey = ['lines', 'color']))
+ gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
+ pos = (row, 5))
boxSizer.Add(item = gridSizer, proportion = 1,
- flag = wx.ALL | wx.EXPAND, border = 3)
+ flag = wx.ALL | wx.EXPAND, border = 5)
pageSizer.Add(item = boxSizer, proportion = 0,
flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
- border = 3)
+ border = 5)
# vector points
- self.win['vector']['points'] = {}
box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
label = " %s " % (_("Vector points")))
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridSizer = wx.GridBagSizer(vgap = 3, hgap = 5)
- # show
row = 0
- showPoints = wx.CheckBox(parent = panel, id = wx.ID_ANY,
- label = _("Show points"))
- showPoints.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
- subkey = ['points', 'show']))
- self.win['vector']['points']['show'] = showPoints.GetId()
- gridSizer.Add(item = showPoints, pos = (row, 0), span = (1, 8))
-
# icon size
- row += 1
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Size:")),
pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
@@ -507,183 +468,104 @@
initial = 100,
min = 1,
max = 1e6)
- self.win['vector']['points']['size'] = isize.GetId()
+ self.winId['nviz:vector:points:size'] = isize.GetId()
isize.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
subkey = ['points', 'size']))
gridSizer.Add(item = isize, pos = (row, 1),
flag = wx.ALIGN_CENTER_VERTICAL)
- # icon width
- gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
- label = _("Width:")),
- pos = (row, 2), flag = wx.ALIGN_CENTER_VERTICAL)
-
- iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
- initial = 2,
- min = 1,
- max = 1e6)
- self.win['vector']['points']['width'] = isize.GetId()
- iwidth.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
- subkey = ['points', 'width']))
- gridSizer.Add(item = iwidth, pos = (row, 3),
- flag = wx.ALIGN_CENTER_VERTICAL)
-
# icon symbol
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Marker:")),
- pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
+ pos = (row, 2), flag = wx.ALIGN_CENTER_VERTICAL)
isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
choices = UserSettings.Get(group = 'nviz', key = 'vector',
subkey = ['points', 'marker'], internal = True))
- isym.SetName("selection")
- self.win['vector']['points']['marker'] = isym.GetId()
+ isym.SetName("GetSelection")
+ self.winId['nviz:vector:points:marker'] = isym.GetId()
isym.SetSelection(UserSettings.Get(group = 'nviz', key = 'vector',
subkey = ['points', 'marker']))
gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
- pos = (row, 5))
+ pos = (row, 3))
# icon color
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
label = _("Color:")),
- pos = (row, 6), flag = wx.ALIGN_CENTER_VERTICAL)
- icolor = csel.ColourSelect(panel, id = wx.ID_ANY)
- icolor.SetName("color")
- self.win['vector']['points']['color'] = icolor.GetId()
+ pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
+ icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
+ size = globalvar.DIALOG_COLOR_SIZE)
+ icolor.SetName('GetColour')
+ self.winId['nviz:vector:points:color'] = icolor.GetId()
icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
subkey = ['points', 'color']))
gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
- pos = (row, 7))
+ pos = (row, 5))
boxSizer.Add(item = gridSizer, proportion = 1,
- flag = wx.ALL | wx.EXPAND, border = 3)
+ flag = wx.ALL | wx.EXPAND, border = 5)
pageSizer.Add(item = boxSizer, proportion = 0,
flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
- border = 3)
+ border = 5)
panel.SetSizer(pageSizer)
return panel
-
- def _getValue(self, win):
- if win.GetName() == "selection":
- value = win.GetSelection()
- elif win.GetName() == "color":
- value = tuple(win.GetColour())
- else:
- value = win.GetValue()
-
- return value
-
+
def OnDefault(self, event):
- """Restore default settings"""
- settings = copy.deepcopy(UserSettings.GetDefaultSettings()['nviz'])
- UserSettings.Set(group = 'nviz',
- value = settings)
+ """!Button 'Set to default' pressed"""
+ self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
- for subgroup, key in settings.iteritems(): # view, surface, vector...
- if subgroup != 'view':
- continue
- for subkey, value in key.iteritems():
- for subvalue in value.keys():
- win = self.FindWindowById(self.win[subgroup][subkey][subvalue])
- val = settings[subgroup][subkey][subvalue]
- if subkey == 'position':
- if val < 1:
- val = int(val * 100)
-
- win.SetValue(val)
+ # update widgets
+ for gks in self.winId.keys():
+ subkey1 = None
+ try:
+ group, key, subkey = gks.split(':')
+ value = self.settings.Get(group, key, subkey)
+ except ValueError:
+ group, key, subkey, subkey1 = gks.split(':')
+ value = self.settings.Get(group, key, [subkey, subkey1])
+ if subkey == 'position':
+ if subkey1 in ('x', 'y'):
+ value = float(value) * 100
+ win = self.FindWindowById(self.winId[gks])
+ if win.GetName() == 'GetSelection':
+ value = win.SetSelection(value)
+ else:
+ value = win.SetValue(value)
- event.Skip()
-
def OnApply(self, event):
"""Apply Nviz settings for current session"""
- settings = UserSettings.Get(group = 'nviz')
- for subgroup, key in settings.iteritems(): # view, surface, vector...
- for subkey, value in key.iteritems():
- if type(value) == types.DictType:
- for subvalue in value.keys():
- try:
- win = self.FindWindowById(self.win[subgroup][subkey][subvalue])
- except KeyError, e:
- #print "error", str(e)+ str(subgroup)+str(subkey)+str(subvalue)
- continue
- value = self._getValue(win)
- if subkey == 'position':
- if subvalue in ('x', 'y'):
- value = float(value) / 100
- settings[subgroup][subkey][subvalue] = value
- else:
- try:
- win = self.FindWindowById(self.win[subgroup][subkey])
- except KeyError, e:
- #print "error", str(subgroup)+" "+str(subkey)+" "+str(value)
- continue
- value = self._getValue(win)
- settings[subgroup][subkey] = value
-
+ for item in self.winId.keys():
+ try:
+ group, key, subkey = item.split(':')
+ subkey1 = None
+ except ValueError:
+ group, key, subkey, subkey1 = item.split(':')
+
+ id = self.winId[item]
+ win = self.FindWindowById(id)
+ if win.GetName() == 'GetSelection':
+ value = win.GetSelection()
+ elif win.GetName() == 'GetColour':
+ value = tuple(win.GetValue())
+ else:
+ value = win.GetValue()
+
+ if subkey == 'position':
+ if subkey1 in ('x', 'y'):
+ value = float(value) / 100
+ if subkey1:
+ self.settings.Set(group, value, key, [subkey, subkey1])
+ else:
+ self.settings.Set(group, value, key, subkey)
+
+ self.toolWin.LoadSettings()
- def OnLoad(self, event):
- """!Apply button pressed"""
- self.LoadSettings()
-
- if event:
- event.Skip()
-
- def LoadSettings(self):
- """!Load saved Nviz settings and apply to current session"""
- UserSettings.ReadSettingsFile()
- settings = copy.deepcopy(UserSettings.Get(group = 'nviz'))
-
- for subgroup, key in settings.iteritems(): # view, surface, vector...
- for subkey, value in key.iteritems():
- for subvalue in value.keys():
- if subvalue == 'step':
- continue
- else:
- insetting = value[subvalue]
- if subgroup == 'view':
- for viewkey, viewitem in self.mapWindow.view[subkey].iteritems():
- if viewkey == subvalue:
- self.mapWindow.view[subkey][viewkey] = insetting
- else:
- continue
- else:
- for otherkey, otheritem in self.win[subgroup][subkey].iteritems():
- if type(otheritem) == data:
- for endkey, enditem in otheritem.iteritems():
- if endkey == subvalue:
- paramwin = self.FindWindowById(enditem)
- else:
- continue
- else:
- if otherkey == subvalue:
- paramwin = self.FindWindowById(otheritem)
- else:
- continue
- if type(insetting) in [tuple, list] and len(insetting) > 2:
- insetting = tuple(insetting)
- paramwin.SetColour(insetting)
- else:
- try:
- paramwin.SetValue(insetting)
- except:
- try:
- paramwin.SetStringSelection(insetting)
- except:
- continue
-
- self.toolWin.UpdateSettings()
- self.FindWindowById(self.win['view']['position']).Draw()
- self.FindWindowById(self.win['view']['position']).Refresh(False)
-
- self.mapWindow.render['quick'] = False
- self.mapWindow.Refresh(False)
-
def OnSave(self, event):
"""!Save button pressed
- Save settings to configuration file
+ Apply changes and save settings to configuration file
"""
self.OnApply(None)
fileSettings = {}
@@ -691,7 +573,7 @@
fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
UserSettings.SaveToFile(fileSettings)
- self.parent.GetLayerManager().goutput.WriteLog(
+ self.parent.goutput.WriteLog(
_('3D view settings saved to file <%s>.') % UserSettings.filePath)
self.Destroy()
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -232,12 +232,29 @@
if 'view' in kwargs:
self.mapWindow.view = kwargs['view']
self.FindWindowById(self.win['view']['position']).data = kwargs['view']
+ self.FindWindowById(self.win['view']['position']).PostDraw()
if 'iview' in kwargs:
self.mapWindow.iview = kwargs['iview']
if 'light' in kwargs:
self.mapWindow.light = kwargs['light']
self.FindWindowById(self.win['light']['position']).data = kwargs['light']
-
+ self.FindWindowById(self.win['light']['position']).PostDraw()
+
+ def LoadSettings(self):
+ """!Load Nviz settings and apply to current session"""
+ view = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'view')) # copy
+ light = copy.deepcopy(UserSettings.Get(group = 'nviz', key = 'light')) # copy
+ self.UpdateState(view = view, light = light)
+ self.PostViewEvent(zExag = True)
+ self.PostLightEvent()
+ self.UpdatePage('view')
+ self.UpdatePage('light')
+
+ self.mapWindow.ReloadLayersData()
+ self.UpdatePage('surface')
+ self.UpdatePage('vector')
+ self.UpdateSettings()
+
def OnPageChanged(self, event):
new = event.GetSelection()
# self.ChangeSelection(new)
@@ -247,6 +264,11 @@
event = wxUpdateView(zExag = zExag)
wx.PostEvent(self.mapWindow, event)
+ def PostLightEvent(self, refresh = False):
+ """!Change light settings"""
+ event = wxUpdateLight(refresh = refresh)
+ wx.PostEvent(self.mapWindow, event)
+
def OnSize(self, event):
"""!After window is resized, update scrolling"""
# workaround to resize captionbars of foldpanelbar
@@ -2374,8 +2396,7 @@
for win in self.win['light'][winName].itervalues():
self.FindWindowById(win).SetValue(value)
- event = wxUpdateLight()
- wx.PostEvent(self.mapWindow, event)
+ self.PostLightEvent(refresh = False)
event.Skip()
@@ -2387,8 +2408,7 @@
"""!Color of the light changed"""
self.mapWindow.light['color'] = tuple(event.GetValue())
- event = wxUpdateLight(refresh = True)
- wx.PostEvent(self.mapWindow, event)
+ self.PostLightEvent()
event.Skip()
@@ -2397,8 +2417,7 @@
data = self.mapWindow.light
self.OnScroll(event, self.win['light'], data)
- event = wxUpdateLight()
- wx.PostEvent(self.mapWindow, event)
+ self.PostLightEvent()
event.Skip()
def OnBgColor(self, event):
@@ -2608,8 +2627,7 @@
self.UpdateSettings()
else:
- event = wxUpdateLight()
- wx.PostEvent(self.mapWindow, event)
+ self.PostLightEvent()
lightWin = self.FindWindowById(self.win['light']['position'])
x, y = lightWin.UpdatePos(self.mapWindow.light['position']['x'],
self.mapWindow.light['position']['y'])
@@ -3996,6 +4014,7 @@
else: return
if event.GetInt():
+ self.mapWindow.parent.Raise()
self.mapWindow.mouse['use'] = type
self.mapWindow.SetCursor(self.mapWindow.cursors["cross"])
else:
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -473,17 +473,13 @@
'x' : 0.84,
'y' : 0.16,
},
- 'height' : {
- 'step' : 100,
- },
'twist' : {
'value' : 0,
- 'step' : 5,
},
'z-exag' : {
- 'step' : 1,
'min' : 0,
'max' : 10,
+ 'value': 1,
},
'background' : {
'color' : (255, 255, 255, 255), # white
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -491,24 +491,20 @@
iview['persp']['min'] = self.__processLayerNvizNode(node_persp, 'min', int)
iview['persp']['max'] = self.__processLayerNvizNode(node_persp, 'max', int)
node_height = node_view.find('v_height')
- view['height'] = {}
iview['height'] = {}
iview['height']['value'] = self.__processLayerNvizNode(node_height, 'value', int)
- view['height']['step'] = self.__processLayerNvizNode(node_height, 'step', int)
iview['height']['min'] = self.__processLayerNvizNode(node_height, 'min', int)
iview['height']['max'] = self.__processLayerNvizNode(node_height, 'max', int)
node_twist = node_view.find('twist')
view['twist'] = {}
iview['twist'] = {}
view['twist']['value'] = self.__processLayerNvizNode(node_twist, 'value', int)
- view['twist']['step'] = self.__processLayerNvizNode(node_twist, 'step', int)
iview['twist']['min'] = self.__processLayerNvizNode(node_twist, 'min', int)
iview['twist']['max'] = self.__processLayerNvizNode(node_twist, 'max', int)
node_zexag = node_view.find('z-exag')
view['z-exag'] = {}
iview['z-exag'] = {}
view['z-exag']['value'] = self.__processLayerNvizNode(node_zexag, 'value', int)
- view['z-exag']['step'] = self.__processLayerNvizNode(node_zexag, 'step', int)
view['z-exag']['min'] = self.__processLayerNvizNode(node_zexag, 'min', int)
view['z-exag']['max'] = self.__processLayerNvizNode(node_zexag, 'max', int)
iview['z-exag']['original'] = self.__processLayerNvizNode(node_zexag, 'original', float)
@@ -559,6 +555,7 @@
def __init__(self):
"""Default 3D settings"""
UserSettings.Reset('nviz')
+ UserSettings.ReadSettingsFile()
def SetConstantDefaultProp(self):
"""Set default constant data properties"""
@@ -570,9 +567,10 @@
return data
- def SetSurfaceDefaultProp(self):
+ def SetSurfaceDefaultProp(self, data = None):
"""Set default surface data properties"""
- data = dict()
+ if not data:
+ data = dict()
for sec in ('attribute', 'draw', 'mask', 'position'):
data[sec] = {}
@@ -693,9 +691,10 @@
subkey = 'transp'))
return data
- def SetVectorDefaultProp(self):
+ def SetVectorDefaultProp(self, data = None):
"""Set default vector data properties"""
- data = dict()
+ if not data:
+ data = dict()
for sec in ('lines', 'points'):
data[sec] = {}
@@ -740,7 +739,7 @@
'usecolor' : False,
'usewidth' : False}
if 'object' in data:
- for attrb in ('color', 'width', 'mode', 'height'):
+ for attrb in ('color', 'width', 'mode', 'height', 'thematic'):
data[attrb]['update'] = None
def SetVectorPointsDefaultProp(self, data):
@@ -780,7 +779,7 @@
'usesize' : False}
if 'object' in data:
for attrb in ('size', 'width', 'marker',
- 'color', 'surface', 'height', 'thematic'):
+ 'color', 'height', 'thematic'):
data[attrb]['update'] = None
def GetDrawMode(self, mode=None, style=None, shade=None, string=False):
@@ -1229,7 +1228,6 @@
self.file.write('%s<v_height>\n' % (' ' * self.indent))
self.indent += 4
self.file.write('%s<value>%d</value>\n' % (' ' * self.indent, iview['height']['value']))
- self.file.write('%s<step>%d</step>\n' % (' ' * self.indent, view['height']['step']))
self.file.write('%s<min>%d</min>\n' % (' ' * self.indent, iview['height']['min']))
self.file.write('%s<max>%d</max>\n' % (' ' * self.indent, iview['height']['max']))
self.indent -= 4
@@ -1238,7 +1236,6 @@
self.file.write('%s<twist>\n' % (' ' * self.indent))
self.indent += 4
self.file.write('%s<value>%d</value>\n' % (' ' * self.indent, view['twist']['value']))
- self.file.write('%s<step>%d</step>\n' % (' ' * self.indent, view['twist']['step']))
self.file.write('%s<min>%d</min>\n' % (' ' * self.indent, iview['twist']['min']))
self.file.write('%s<max>%d</max>\n' % (' ' * self.indent, iview['twist']['max']))
self.indent -= 4
@@ -1247,7 +1244,6 @@
self.file.write('%s<z-exag>\n' % (' ' * self.indent))
self.indent += 4
self.file.write('%s<value>%d</value>\n' % (' ' * self.indent, view['z-exag']['value']))
- self.file.write('%s<step>%d</step>\n' % (' ' * self.indent, view['z-exag']['step']))
self.file.write('%s<min>%d</min>\n' % (' ' * self.indent, view['z-exag']['min']))
self.file.write('%s<max>%d</max>\n' % (' ' * self.indent, view['z-exag']['max']))
self.file.write('%s<original>%d</original>\n' % (' ' * self.indent, iview['z-exag']['original']))
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2011-08-23 14:12:07 UTC (rev 47848)
+++ grass/trunk/gui/wxpython/wxgui.py 2011-08-23 14:15:29 UTC (rev 47849)
@@ -897,7 +897,7 @@
mdisp.MapWindow2D.UpdateMap()
#nviz
if gxwXml.displays[idx]['viewMode'] == '3d':
- mdisp.AddToolbar(name = 'nviz')
+ mdisp.AddNviz()
self.nviz.UpdateState(view = gxwXml.nviz_state['view'],
iview = gxwXml.nviz_state['iview'],
light = gxwXml.nviz_state['light'])
More information about the grass-commit
mailing list