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',
'inout'):
147 data[attr][
'update'] =
None
149 data[attr][
'value'] = 0
151 for key, value
in UserSettings.Get(group =
'nviz', key =
'volume',
152 subkey = attr).iteritems():
153 data[attr][key] = value
157 """!Set default slice properties"""
159 data[
'position'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'volume',
160 subkey =
'slice_position'))
161 data[
'position'][
'update'] =
None
163 data[
'transp'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'volume',
168 """Set default vector data properties"""
171 for sec
in (
'lines',
'points'):
180 """Set default vector properties -- lines"""
182 data[
'width'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
183 subkey=[
'lines',
'width']) }
186 value = UserSettings.Get(group=
'nviz', key=
'vector',
187 subkey=[
'lines',
'color'])
188 color = str(value[0]) +
':' + str(value[1]) +
':' + str(value[2])
189 data[
'color'] = {
'value' : color }
192 if UserSettings.Get(group=
'nviz', key=
'vector',
193 subkey=[
'lines',
'flat']):
200 data[
'mode'][
'type'] = type
201 data[
'mode'][
'update'] =
None
204 data[
'height'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
205 subkey=[
'lines',
'height']) }
207 for attrb
in (
'color',
'width',
'mode',
'height'):
208 data[attrb][
'update'] =
None
211 """Set default vector properties -- points"""
213 data[
'size'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
214 subkey=[
'points',
'size']) }
217 data[
'width'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
218 subkey=[
'points',
'width']) }
221 data[
'marker'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
222 subkey=[
'points',
'marker']) }
225 value = UserSettings.Get(group=
'nviz', key=
'vector',
226 subkey=[
'points',
'color'])
227 color = str(value[0]) +
':' + str(value[1]) +
':' + str(value[2])
228 data[
'color'] = {
'value' : color }
231 data[
'mode'] = {
'type' :
'surface'}
235 data[
'height'] = {
'value' : UserSettings.Get(group=
'nviz', key=
'vector',
236 subkey=[
'points',
'height']) }
239 for attrb
in (
'size',
'width',
'marker',
'color',
'height'):
240 data[attrb][
'update'] =
None
242 def GetDrawMode(self, mode=None, style=None, shade=None, string=False):
243 """Get surface draw mode (value) from description/selection
245 @param mode,style,shade modes
246 @param string if True input parameters are strings otherwise
258 value |= wxnviz.DM_WIRE
260 value |= wxnviz.DM_POLY
262 value |= wxnviz.DM_WIRE_POLY
264 if style
is not None:
266 value |= wxnviz.DM_GRID_WIRE
268 value |= wxnviz.DM_GRID_SURF
270 if shade
is not None:
272 value |= wxnviz.DM_FLAT
274 value |= wxnviz.DM_GOURAUD
281 value |= wxnviz.DM_WIRE
282 desc[
'mode'] =
'coarse'
284 value |= wxnviz.DM_POLY
285 desc[
'mode'] =
'fine'
287 value |= wxnviz.DM_WIRE_POLY
288 desc[
'mode'] =
'both'
290 if style
is not None:
292 value |= wxnviz.DM_GRID_WIRE
293 desc[
'style'] =
'wire'
295 value |= wxnviz.DM_GRID_SURF
296 desc[
'style'] =
'surface'
298 if shade
is not None:
300 value |= wxnviz.DM_FLAT
301 desc[
'shading'] =
'flat'
303 value |= wxnviz.DM_GOURAUD
304 desc[
'shading'] =
'gouraud'
309 """!Set default arrow properties
315 data[
'arrow'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'arrow'))
316 data[
'arrow'][
'color'] =
"%d:%d:%d" % (
317 UserSettings.Get(group =
'nviz', key =
'arrow', subkey =
'color')[:3])
318 data[
'arrow'].
update(copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'arrow', internal =
True)))
319 data[
'arrow'][
'show'] =
False
322 if type ==
'scalebar':
323 data[
'scalebar'] = copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'scalebar'))
324 data[
'scalebar'][
'color'] =
"%d:%d:%d" % (
325 UserSettings.Get(group =
'nviz', key =
'scalebar', subkey =
'color')[:3])
326 data[
'scalebar'].
update(copy.deepcopy(UserSettings.Get(group =
'nviz', key =
'scalebar', internal =
True)))
327 data[
'scalebar'][
'id'] = 0
def SetSurfaceDefaultProp
def SetSliceDefaultProp(self)
Set default slice properties.
def SetVectorLinesDefaultProp(self, data)
def SetConstantDefaultProp(self)
def SetVectorPointsDefaultProp(self, data)
def SetVolumeDefaultProp(self)
def SetIsosurfaceDefaultProp(self)
Set default isosurface properties.
def SetDecorDefaultProp(self, type)
Set default arrow properties.