2 @package nviz.workspace
4 @brief wxNviz workspace settings
7 - workspace::NvizSettings
9 (C) 2007-2011 by the GRASS Development Team
11 This program is free software under the GNU General Public License
12 (>=v2). Read the file COPYING that comes with GRASS for details.
14 @author Anna Kratochvilova <kratochanna gmail.com> (wxNviz / Google SoC 2011)
22 from nviz
import wxnviz
31 """Set default constant data properties"""
33 for key, value
in UserSettings.Get(group=
'nviz', key=
'constant').iteritems():
35 color = str(data[
'color'][0]) +
':' + str(data[
'color'][1]) +
':' + str(data[
'color'][2])
41 """Set default surface data properties"""
44 for sec
in (
'attribute',
'draw',
'mask',
'position'):
50 for attrb
in (
'shine', ):
51 data[
'attribute'][attrb] = {}
52 for key, value
in UserSettings.Get(group=
'nviz', key=
'surface',
53 subkey=attrb).iteritems():
54 data[
'attribute'][attrb][key] = value
55 data[
'attribute'][attrb][
'update'] =
None
60 data[
'draw'][
'all'] =
False
61 for control, value
in UserSettings.Get(group=
'nviz', key=
'surface', subkey=
'draw').iteritems():
62 if control[:3] ==
'res':
63 if 'resolution' not in data[
'draw']:
64 data[
'draw'][
'resolution'] = {}
65 if 'update' not in data[
'draw'][
'resolution']:
66 data[
'draw'][
'resolution'][
'update'] =
None
67 data[
'draw'][
'resolution'][control[4:]] = value
70 if control ==
'wire-color':
71 value = str(value[0]) +
':' + str(value[1]) +
':' + str(value[2])
72 elif control
in (
'mode',
'style',
'shading'):
73 if 'mode' not in data[
'draw']:
74 data[
'draw'][
'mode'] = {}
77 data[
'draw'][control] = {
'value' : value }
78 data[
'draw'][control][
'update'] =
None
80 value, desc = self.GetDrawMode(UserSettings.Get(group=
'nviz', key=
'surface', subkey=[
'draw',
'mode']),
81 UserSettings.Get(group=
'nviz', key=
'surface', subkey=[
'draw',
'style']),
82 UserSettings.Get(group=
'nviz', key=
'surface', subkey=[
'draw',
'shading']))
84 data[
'draw'][
'mode'] = {
'value' : value,
88 for coord
in (
'x',
'y',
'z'):
89 data[
'position'][coord] = UserSettings.Get(group=
'nviz', key=
'surface', subkey=[
'position', coord])
90 data[
'position'][
'update'] =
None
95 """Set default volume data properties"""
97 for sec
in (
'attribute',
'draw',
'position'):
99 for sec
in (
'isosurface',
'slice'):
105 for control, value
in UserSettings.Get(group=
'nviz', key=
'volume', subkey=
'draw').iteritems():
106 if control ==
'shading':
107 sel = UserSettings.Get(group=
'nviz', key=
'volume', subkey=[
'draw',
'shading'])
108 value, desc = self.GetDrawMode(shade=sel, string=
False)
110 data[
'draw'][
'shading'] = {}
111 data[
'draw'][
'shading'][
'isosurface'] = {
'value' : value,
112 'desc' : desc[
'shading'] }
113 data[
'draw'][
'shading'][
'slice'] = {
'value' : value,
114 'desc' : desc[
'shading'] }
115 elif control ==
'mode':
116 sel = UserSettings.Get(group=
'nviz', key=
'volume', subkey=[
'draw',
'mode'])
121 data[
'draw'][
'mode'] = {
'value' : sel,
124 data[
'draw'][control] = {}
125 data[
'draw'][control][
'isosurface'] = {
'value' : value }
126 data[
'draw'][control][
'slice'] = {
'value' : value }
128 if 'update' not in data[
'draw'][control]:
129 data[
'draw'][control][
'update'] =
None
134 for attrb
in (
'shine', ):
135 data[
'attribute'][attrb] = {}
136 for key, value
in UserSettings.Get(group=
'nviz', key=
'volume',
137 subkey=attrb).iteritems():
138 data[
'attribute'][attrb][key] = value
143 """!Set default isosurface properties"""
145 for attr
in (
'shine',
'topo',
'transp',
'color'):
147 for key, value
in UserSettings.Get(group =
'nviz', key =
'volume',
148 subkey = attr).iteritems():
149 data[attr][key] = value
150 data[attr][
'update'] =
None
154 """!Set default slice properties"""
156 data[
'position'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'volume',
157 subkey =
'slice_position'))
158 data[
'position'][
'update'] =
None
160 data[
'transp'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'volume',
165 """Set default vector data properties"""
168 for sec
in (
'lines',
'points'):
177 """Set default vector properties -- lines"""
179 data[
'width'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
180 subkey=[
'lines',
'width']) }
183 value = UserSettings.Get(group=
'nviz', key=
'vector',
184 subkey=[
'lines',
'color'])
185 color = str(value[0]) +
':' + str(value[1]) +
':' + str(value[2])
186 data[
'color'] = {
'value' : color }
189 if UserSettings.Get(group=
'nviz', key=
'vector',
190 subkey=[
'lines',
'flat']):
197 data[
'mode'][
'type'] = type
198 data[
'mode'][
'update'] =
None
201 data[
'height'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
202 subkey=[
'lines',
'height']) }
204 for attrb
in (
'color',
'width',
'mode',
'height'):
205 data[attrb][
'update'] =
None
208 """Set default vector properties -- points"""
210 data[
'size'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
211 subkey=[
'points',
'size']) }
214 data[
'width'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
215 subkey=[
'points',
'width']) }
218 data[
'marker'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
219 subkey=[
'points',
'marker']) }
222 value = UserSettings.Get(group=
'nviz', key=
'vector',
223 subkey=[
'points',
'color'])
224 color = str(value[0]) +
':' + str(value[1]) +
':' + str(value[2])
225 data[
'color'] = {
'value' : color }
228 data[
'mode'] = {
'type' :
'surface'}
232 data[
'height'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
233 subkey=[
'points',
'height']) }
236 for attrb
in (
'size',
'width',
'marker',
'color',
'height'):
237 data[attrb][
'update'] =
None
239 def GetDrawMode(self, mode=None, style=None, shade=None, string=False):
240 """Get surface draw mode (value) from description/selection
242 @param mode,style,shade modes
243 @param string if True input parameters are strings otherwise
255 value |= wxnviz.DM_WIRE
257 value |= wxnviz.DM_POLY
259 value |= wxnviz.DM_WIRE_POLY
261 if style
is not None:
263 value |= wxnviz.DM_GRID_WIRE
265 value |= wxnviz.DM_GRID_SURF
267 if shade
is not None:
269 value |= wxnviz.DM_FLAT
271 value |= wxnviz.DM_GOURAUD
278 value |= wxnviz.DM_WIRE
279 desc[
'mode'] =
'coarse'
281 value |= wxnviz.DM_POLY
282 desc[
'mode'] =
'fine'
284 value |= wxnviz.DM_WIRE_POLY
285 desc[
'mode'] =
'both'
287 if style
is not None:
289 value |= wxnviz.DM_GRID_WIRE
290 desc[
'style'] =
'wire'
292 value |= wxnviz.DM_GRID_SURF
293 desc[
'style'] =
'surface'
295 if shade
is not None:
297 value |= wxnviz.DM_FLAT
298 desc[
'shading'] =
'flat'
300 value |= wxnviz.DM_GOURAUD
301 desc[
'shading'] =
'gouraud'
306 """!Set default arrow properties
312 data[
'arrow'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'arrow'))
313 data[
'arrow'][
'color'] =
"%d:%d:%d" % (
314 UserSettings.Get(group =
'nviz', key =
'arrow', subkey =
'color')[:3])
315 data[
'arrow'].
update(copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'arrow', internal =
True)))
316 data[
'arrow'][
'show'] =
False
319 if type ==
'scalebar':
320 data[
'scalebar'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'scalebar'))
321 data[
'scalebar'][
'color'] =
"%d:%d:%d" % (
322 UserSettings.Get(group =
'nviz', key =
'scalebar', subkey =
'color')[:3])
323 data[
'scalebar'].
update(copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'scalebar', internal =
True)))
324 data[
'scalebar'][
'id'] = 0
def SetDecorDefaultProp
Set default arrow properties.
def SetIsosurfaceDefaultProp
Set default isosurface properties.
def SetVectorLinesDefaultProp
def SetSurfaceDefaultProp
def SetVectorPointsDefaultProp
def SetConstantDefaultProp
def SetSliceDefaultProp
Set default slice properties.