nviz_preferences.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. """
  2. @package nviz_preferences.py
  3. @brief Nviz (3D view) preferences window
  4. Classes:
  5. - NvizPreferencesDialog
  6. (C) 2008-2011 by the GRASS Development Team
  7. This program is free software under the GNU General Public License
  8. (>=v2). Read the file COPYING that comes with GRASS for details.
  9. @author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
  10. @author Enhancements by Michael Barton <michael.barton asu.edu>
  11. @author Anna Kratochvilova <KratochAnna seznam.cz> (Google SoC 2011)
  12. """
  13. import types
  14. import copy
  15. import wx
  16. import wx.lib.colourselect as csel
  17. import globalvar
  18. from preferences import globalSettings as UserSettings
  19. from preferences import PreferencesBaseDialog
  20. class NvizPreferencesDialog(PreferencesBaseDialog):
  21. """!Nviz preferences dialog"""
  22. def __init__(self, parent, title = _("3D view settings"),
  23. settings = UserSettings):
  24. PreferencesBaseDialog.__init__(self, parent = parent, title = title,
  25. settings = settings)
  26. self.toolWin = self.parent.nviz
  27. # create notebook pages
  28. self._createViewPage(self.notebook)
  29. self._createLightPage(self.notebook)
  30. self._createSurfacePage(self.notebook)
  31. self._createVectorPage(self.notebook)
  32. self.SetMinSize(self.GetBestSize())
  33. self.SetSize(self.size)
  34. self.btnDefault.SetToolTipString(_("Revert settings to default, changes are not applied"))
  35. def _createViewPage(self, notebook):
  36. """!Create notebook page for view settings"""
  37. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  38. notebook.AddPage(page = panel,
  39. text = " %s " % _("View"))
  40. pageSizer = wx.BoxSizer(wx.VERTICAL)
  41. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  42. label = " %s " % (_("View")))
  43. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  44. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  45. row = 0
  46. # perspective
  47. pvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'persp')
  48. ipvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'persp', internal = True)
  49. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  50. label = _("Perspective:")),
  51. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  52. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  53. label = _("value:")),
  54. pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  55. pval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  56. initial = pvals['value'],
  57. min = ipvals['min'],
  58. max = ipvals['max'])
  59. self.winId['nviz:view:persp:value'] = pval.GetId()
  60. gridSizer.Add(item = pval, pos = (row, 2),
  61. flag = wx.ALIGN_CENTER_VERTICAL)
  62. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  63. label = _("step:")),
  64. pos = (row, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  65. pstep = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  66. initial = pvals['step'],
  67. min = ipvals['min'],
  68. max = ipvals['max']-1)
  69. self.winId['nviz:view:persp:step'] = pstep.GetId()
  70. gridSizer.Add(item = pstep, pos = (row, 4),
  71. flag = wx.ALIGN_CENTER_VERTICAL)
  72. row += 1
  73. # position
  74. posvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'position')
  75. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  76. label = _("Position:")),
  77. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  78. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  79. label = _("x:")),
  80. pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  81. px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  82. initial = posvals['x'] * 100,
  83. min = 0,
  84. max = 100)
  85. self.winId['nviz:view:position:x'] = px.GetId()
  86. gridSizer.Add(item = px, pos = (row, 2),
  87. flag = wx.ALIGN_CENTER_VERTICAL)
  88. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  89. label = "y:"),
  90. pos = (row, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  91. py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  92. initial = posvals['y'] * 100,
  93. min = 0,
  94. max = 100)
  95. self.winId['nviz:view:position:y'] = py.GetId()
  96. gridSizer.Add(item = py, pos = (row, 4),
  97. flag = wx.ALIGN_CENTER_VERTICAL)
  98. row += 1
  99. # height is computed dynamically
  100. # twist
  101. tvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'twist')
  102. itvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'twist', internal = True)
  103. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  104. label = _("Twist:")),
  105. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  106. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  107. label = _("value:")),
  108. pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  109. tval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  110. initial = tvals['value'],
  111. min = itvals['min'],
  112. max = itvals['max'])
  113. self.winId['nviz:view:twist:value'] = tval.GetId()
  114. gridSizer.Add(item = tval, pos = (row, 2),
  115. flag = wx.ALIGN_CENTER_VERTICAL)
  116. row += 1
  117. # z-exag
  118. zvals = UserSettings.Get(group = 'nviz', key = 'view', subkey = 'z-exag')
  119. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  120. label = _("Z-exag:")),
  121. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  122. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  123. label = _("value:")),
  124. pos = (row, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  125. zval = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  126. initial = zvals['value'],
  127. min = -1e6,
  128. max = 1e6)
  129. self.winId['nviz:view:z-exag:value'] = zval.GetId()
  130. gridSizer.Add(item = zval, pos = (row, 2),
  131. flag = wx.ALIGN_CENTER_VERTICAL)
  132. boxSizer.Add(item = gridSizer, proportion = 1,
  133. flag = wx.ALL | wx.EXPAND, border = 3)
  134. pageSizer.Add(item = boxSizer, proportion = 0,
  135. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  136. border = 3)
  137. box = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  138. label = " %s " % (_("Image Appearance")))
  139. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  140. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  141. gridSizer.AddGrowableCol(0)
  142. # background color
  143. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  144. label = _("Background color:")),
  145. pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  146. color = csel.ColourSelect(panel, id = wx.ID_ANY,
  147. colour = UserSettings.Get(group = 'nviz', key = 'view',
  148. subkey = ['background', 'color']),
  149. size = globalvar.DIALOG_COLOR_SIZE)
  150. color.SetName('GetColour')
  151. self.winId['nviz:view:background:color'] = color.GetId()
  152. gridSizer.Add(item = color, pos = (0, 1))
  153. boxSizer.Add(item = gridSizer, proportion = 1,
  154. flag = wx.ALL | wx.EXPAND, border = 5)
  155. pageSizer.Add(item = boxSizer, proportion = 0,
  156. flag = wx.EXPAND | wx.ALL,
  157. border = 5)
  158. panel.SetSizer(pageSizer)
  159. return panel
  160. def _createLightPage(self, notebook):
  161. """!Create notebook page for light settings"""
  162. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  163. notebook.AddPage(page = panel,
  164. text = " %s " % _("Lighting"))
  165. pageSizer = wx.BoxSizer(wx.VERTICAL)
  166. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  167. label = " %s " % (_("Light")))
  168. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  169. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  170. # position
  171. posvals = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'position')
  172. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  173. label = _("Position:")),
  174. pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  175. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  176. label = _("x:")),
  177. pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  178. px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  179. initial = posvals['x'] * 100,
  180. min = -100,
  181. max = 100)
  182. self.winId['nviz:light:position:x'] = px.GetId()
  183. gridSizer.Add(item = px, pos = (0, 2),
  184. flag = wx.ALIGN_CENTER_VERTICAL)
  185. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  186. label = "y:"),
  187. pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  188. py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  189. initial = posvals['y'] * 100,
  190. min = -100,
  191. max = 100)
  192. self.winId['nviz:light:position:y'] = py.GetId()
  193. gridSizer.Add(item = py, pos = (0, 4),
  194. flag = wx.ALIGN_CENTER_VERTICAL)
  195. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  196. label = _("z:")),
  197. pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  198. pz = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  199. initial = posvals['z'],
  200. min = 0,
  201. max = 100)
  202. self.winId['nviz:light:position:z'] = pz.GetId()
  203. gridSizer.Add(item = pz, pos = (0, 6),
  204. flag = wx.ALIGN_CENTER_VERTICAL)
  205. # brightness
  206. brightval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'bright')
  207. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  208. label = _("Brightness:")),
  209. pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  210. bright = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  211. initial = brightval,
  212. min = 0,
  213. max = 100)
  214. self.winId['nviz:light:bright'] = bright.GetId()
  215. gridSizer.Add(item = bright, pos = (1, 2),
  216. flag = wx.ALIGN_CENTER_VERTICAL)
  217. # ambient
  218. ambval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'ambient')
  219. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  220. label = _("Ambient:")),
  221. pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  222. amb = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  223. initial = ambval,
  224. min = 0,
  225. max = 100)
  226. self.winId['nviz:light:ambient'] = amb.GetId()
  227. gridSizer.Add(item = amb, pos = (2, 2),
  228. flag = wx.ALIGN_CENTER_VERTICAL)
  229. # light color
  230. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  231. label = _("Color:")),
  232. pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  233. color = csel.ColourSelect(panel, id = wx.ID_ANY,
  234. colour = UserSettings.Get(group = 'nviz', key = 'light',
  235. subkey = 'color'),
  236. size = globalvar.DIALOG_COLOR_SIZE)
  237. color.SetName('GetColour')
  238. self.winId['nviz:light:color'] = color.GetId()
  239. gridSizer.Add(item = color, pos = (3, 2))
  240. boxSizer.Add(item = gridSizer, proportion = 1,
  241. flag = wx.ALL | wx.EXPAND, border = 5)
  242. pageSizer.Add(item = boxSizer, proportion = 0,
  243. flag = wx.EXPAND | wx.ALL,
  244. border = 5)
  245. panel.SetSizer(pageSizer)
  246. return panel
  247. def _createSurfacePage(self, notebook):
  248. """!Create notebook page for surface settings"""
  249. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  250. notebook.AddPage(page = panel,
  251. text = " %s " % _("Surface"))
  252. pageSizer = wx.BoxSizer(wx.VERTICAL)
  253. # draw
  254. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  255. label = " %s " % (_("Draw")))
  256. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  257. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  258. # mode
  259. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  260. label = _("Mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
  261. pos = (0, 0))
  262. mode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
  263. choices = [_("coarse"),
  264. _("fine"),
  265. _("both")])
  266. self.winId['nviz:surface:draw:mode'] = mode.GetId()
  267. mode.SetName('GetSelection')
  268. mode.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
  269. subkey = ['draw', 'mode']))
  270. gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
  271. pos = (0, 1))
  272. # fine
  273. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  274. label = _("Fine mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
  275. pos = (1, 0))
  276. res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-fine'])
  277. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  278. label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
  279. pos = (1, 1))
  280. fine = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  281. initial = res,
  282. min = 1,
  283. max = 100)
  284. self.winId['nviz:surface:draw:res-fine'] = fine.GetId()
  285. gridSizer.Add(item = fine, flag = wx.ALIGN_CENTER_VERTICAL,
  286. pos = (1, 2))
  287. # coarse
  288. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  289. label = _("Coarse mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
  290. pos = (2, 0))
  291. res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-coarse'])
  292. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  293. label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
  294. pos = (2, 1))
  295. coarse = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  296. initial = res,
  297. min = 1,
  298. max = 100)
  299. self.winId['nviz:surface:draw:res-coarse'] = coarse.GetId()
  300. gridSizer.Add(item = coarse, flag = wx.ALIGN_CENTER_VERTICAL,
  301. pos = (2, 2))
  302. #style
  303. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  304. label = _("style:")), flag = wx.ALIGN_CENTER_VERTICAL,
  305. pos = (3, 1))
  306. style = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
  307. choices = [_("wire"),
  308. _("surface")])
  309. self.winId['nviz:surface:draw:style'] = style.GetId()
  310. style.SetName('GetSelection')
  311. style.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
  312. subkey = ['draw', 'style']))
  313. self.winId['nviz:surface:draw:style'] = style.GetId()
  314. gridSizer.Add(item = style, flag = wx.ALIGN_CENTER_VERTICAL,
  315. pos = (3, 2))
  316. #wire color
  317. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  318. label = _("wire color:")), flag = wx.ALIGN_CENTER_VERTICAL,
  319. pos = (4, 1))
  320. color = csel.ColourSelect(panel, id = wx.ID_ANY,
  321. colour = UserSettings.Get(group = 'nviz', key = 'surface',
  322. subkey = ['draw', 'wire-color']),
  323. size = globalvar.DIALOG_COLOR_SIZE)
  324. color.SetName('GetColour')
  325. self.winId['nviz:surface:draw:wire-color'] = color.GetId()
  326. gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL,
  327. pos = (4, 2))
  328. boxSizer.Add(item = gridSizer, proportion = 1,
  329. flag = wx.ALL | wx.EXPAND, border = 5)
  330. pageSizer.Add(item = boxSizer, proportion = 0,
  331. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  332. border = 5)
  333. panel.SetSizer(pageSizer)
  334. return panel
  335. def _createVectorPage(self, notebook):
  336. """!Create notebook page for vector settings"""
  337. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  338. notebook.AddPage(page = panel,
  339. text = " %s " % _("Vector"))
  340. pageSizer = wx.BoxSizer(wx.VERTICAL)
  341. # vector lines
  342. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  343. label = " %s " % (_("Vector lines")))
  344. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  345. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  346. row = 0
  347. # icon size
  348. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  349. label = _("Width:")),
  350. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  351. iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  352. initial = 12,
  353. min = 1,
  354. max = 100)
  355. self.winId['nviz:vector:lines:width'] = iwidth.GetId()
  356. iwidth.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
  357. subkey = ['lines', 'width']))
  358. gridSizer.Add(item = iwidth, pos = (row, 1),
  359. flag = wx.ALIGN_CENTER_VERTICAL)
  360. # icon color
  361. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  362. label = _("Color:")),
  363. pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
  364. icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
  365. size = globalvar.DIALOG_COLOR_SIZE)
  366. icolor.SetName('GetColour')
  367. self.winId['nviz:vector:lines:color'] = icolor.GetId()
  368. icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
  369. subkey = ['lines', 'color']))
  370. gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
  371. pos = (row, 5))
  372. boxSizer.Add(item = gridSizer, proportion = 1,
  373. flag = wx.ALL | wx.EXPAND, border = 5)
  374. pageSizer.Add(item = boxSizer, proportion = 0,
  375. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  376. border = 5)
  377. # vector points
  378. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  379. label = " %s " % (_("Vector points")))
  380. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  381. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 5)
  382. row = 0
  383. # icon size
  384. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  385. label = _("Size:")),
  386. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  387. isize = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  388. initial = 100,
  389. min = 1,
  390. max = 1e6)
  391. self.winId['nviz:vector:points:size'] = isize.GetId()
  392. isize.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
  393. subkey = ['points', 'size']))
  394. gridSizer.Add(item = isize, pos = (row, 1),
  395. flag = wx.ALIGN_CENTER_VERTICAL)
  396. # icon symbol
  397. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  398. label = _("Marker:")),
  399. pos = (row, 2), flag = wx.ALIGN_CENTER_VERTICAL)
  400. isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
  401. choices = UserSettings.Get(group = 'nviz', key = 'vector',
  402. subkey = ['points', 'marker'], internal = True))
  403. isym.SetName("GetSelection")
  404. self.winId['nviz:vector:points:marker'] = isym.GetId()
  405. isym.SetSelection(UserSettings.Get(group = 'nviz', key = 'vector',
  406. subkey = ['points', 'marker']))
  407. gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
  408. pos = (row, 3))
  409. # icon color
  410. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  411. label = _("Color:")),
  412. pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
  413. icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
  414. size = globalvar.DIALOG_COLOR_SIZE)
  415. icolor.SetName('GetColour')
  416. self.winId['nviz:vector:points:color'] = icolor.GetId()
  417. icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
  418. subkey = ['points', 'color']))
  419. gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
  420. pos = (row, 5))
  421. boxSizer.Add(item = gridSizer, proportion = 1,
  422. flag = wx.ALL | wx.EXPAND, border = 5)
  423. pageSizer.Add(item = boxSizer, proportion = 0,
  424. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  425. border = 5)
  426. panel.SetSizer(pageSizer)
  427. return panel
  428. def OnDefault(self, event):
  429. """!Button 'Set to default' pressed"""
  430. self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
  431. # update widgets
  432. for gks in self.winId.keys():
  433. subkey1 = None
  434. try:
  435. group, key, subkey = gks.split(':')
  436. value = self.settings.Get(group, key, subkey)
  437. except ValueError:
  438. group, key, subkey, subkey1 = gks.split(':')
  439. value = self.settings.Get(group, key, [subkey, subkey1])
  440. if subkey == 'position':
  441. if subkey1 in ('x', 'y'):
  442. value = float(value) * 100
  443. win = self.FindWindowById(self.winId[gks])
  444. if win.GetName() == 'GetSelection':
  445. value = win.SetSelection(value)
  446. else:
  447. value = win.SetValue(value)
  448. def OnApply(self, event):
  449. """Apply Nviz settings for current session"""
  450. for item in self.winId.keys():
  451. try:
  452. group, key, subkey = item.split(':')
  453. subkey1 = None
  454. except ValueError:
  455. group, key, subkey, subkey1 = item.split(':')
  456. id = self.winId[item]
  457. win = self.FindWindowById(id)
  458. if win.GetName() == 'GetSelection':
  459. value = win.GetSelection()
  460. elif win.GetName() == 'GetColour':
  461. value = tuple(win.GetValue())
  462. else:
  463. value = win.GetValue()
  464. if subkey == 'position':
  465. if subkey1 in ('x', 'y'):
  466. value = float(value) / 100
  467. if subkey1:
  468. self.settings.Set(group, value, key, [subkey, subkey1])
  469. else:
  470. self.settings.Set(group, value, key, subkey)
  471. self.toolWin.LoadSettings()
  472. def OnSave(self, event):
  473. """!Save button pressed
  474. Apply changes and save settings to configuration file
  475. """
  476. self.OnApply(None)
  477. fileSettings = {}
  478. UserSettings.ReadSettingsFile(settings = fileSettings)
  479. fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
  480. UserSettings.SaveToFile(fileSettings)
  481. self.parent.goutput.WriteLog(
  482. _('3D view settings saved to file <%s>.') % UserSettings.filePath)
  483. self.Destroy()