preferences.py 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. """
  2. @package nviz.preferences
  3. @brief Nviz (3D view) preferences window
  4. Classes:
  5. - preferences::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 copy
  14. import wx
  15. import wx.lib.colourselect as csel
  16. from core import globalvar
  17. from core.settings import UserSettings
  18. from gui_core.preferences import PreferencesBaseDialog
  19. class NvizPreferencesDialog(PreferencesBaseDialog):
  20. """!Nviz preferences dialog"""
  21. def __init__(self, parent, title = _("3D view settings"),
  22. settings = UserSettings):
  23. PreferencesBaseDialog.__init__(self, parent = parent, title = title,
  24. settings = settings)
  25. self.toolWin = self.parent.nviz
  26. # create notebook pages
  27. self._createViewPage(self.notebook)
  28. self._createFlyPage(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 _createFlyPage(self, notebook):
  161. """!Create notebook page for view settings"""
  162. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  163. notebook.AddPage(page = panel,
  164. text = " %s " % _("Fly-through"))
  165. pageSizer = wx.BoxSizer(wx.VERTICAL)
  166. # fly throuhg mode
  167. box = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  168. label = " %s " % (_("Fly-through mode")))
  169. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  170. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  171. gridSizer.AddGrowableCol(0)
  172. # move exag
  173. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  174. label = _("Move exag:")),
  175. pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  176. moveExag = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 20,
  177. initial = UserSettings.Get(group = 'nviz', key = 'fly',
  178. subkey = ['exag', 'move']),
  179. size = (65, -1))
  180. self.winId['nviz:fly:exag:move'] = moveExag.GetId()
  181. gridSizer.Add(item = moveExag, pos = (0, 1))
  182. # turn exag
  183. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  184. label = _("Turn exag:")),
  185. pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  186. turnExag = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 20,
  187. initial = UserSettings.Get(group = 'nviz', key = 'fly',
  188. subkey = ['exag', 'turn']),
  189. size = (65, -1))
  190. self.winId['nviz:fly:exag:turn'] = turnExag.GetId()
  191. gridSizer.Add(item = turnExag, pos = (1, 1))
  192. boxSizer.Add(item = gridSizer, proportion = 1,
  193. flag = wx.ALL | wx.EXPAND, border = 5)
  194. pageSizer.Add(item = boxSizer, proportion = 0,
  195. flag = wx.EXPAND | wx.ALL,
  196. border = 5)
  197. panel.SetSizer(pageSizer)
  198. return panel
  199. def _createLightPage(self, notebook):
  200. """!Create notebook page for light settings"""
  201. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  202. notebook.AddPage(page = panel,
  203. text = " %s " % _("Lighting"))
  204. pageSizer = wx.BoxSizer(wx.VERTICAL)
  205. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  206. label = " %s " % (_("Light")))
  207. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  208. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  209. # position
  210. posvals = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'position')
  211. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  212. label = _("Position:")),
  213. pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  214. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  215. label = _("x:")),
  216. pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  217. px = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  218. initial = posvals['x'] * 100,
  219. min = -100,
  220. max = 100)
  221. self.winId['nviz:light:position:x'] = px.GetId()
  222. gridSizer.Add(item = px, pos = (0, 2),
  223. flag = wx.ALIGN_CENTER_VERTICAL)
  224. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  225. label = "y:"),
  226. pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  227. py = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  228. initial = posvals['y'] * 100,
  229. min = -100,
  230. max = 100)
  231. self.winId['nviz:light:position:y'] = py.GetId()
  232. gridSizer.Add(item = py, pos = (0, 4),
  233. flag = wx.ALIGN_CENTER_VERTICAL)
  234. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  235. label = _("z:")),
  236. pos = (0, 5), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
  237. pz = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  238. initial = posvals['z'],
  239. min = 0,
  240. max = 100)
  241. self.winId['nviz:light:position:z'] = pz.GetId()
  242. gridSizer.Add(item = pz, pos = (0, 6),
  243. flag = wx.ALIGN_CENTER_VERTICAL)
  244. # brightness
  245. brightval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'bright')
  246. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  247. label = _("Brightness:")),
  248. pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  249. bright = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  250. initial = brightval,
  251. min = 0,
  252. max = 100)
  253. self.winId['nviz:light:bright'] = bright.GetId()
  254. gridSizer.Add(item = bright, pos = (1, 2),
  255. flag = wx.ALIGN_CENTER_VERTICAL)
  256. # ambient
  257. ambval = UserSettings.Get(group = 'nviz', key = 'light', subkey = 'ambient')
  258. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  259. label = _("Ambient:")),
  260. pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  261. amb = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  262. initial = ambval,
  263. min = 0,
  264. max = 100)
  265. self.winId['nviz:light:ambient'] = amb.GetId()
  266. gridSizer.Add(item = amb, pos = (2, 2),
  267. flag = wx.ALIGN_CENTER_VERTICAL)
  268. # light color
  269. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  270. label = _("Color:")),
  271. pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  272. color = csel.ColourSelect(panel, id = wx.ID_ANY,
  273. colour = UserSettings.Get(group = 'nviz', key = 'light',
  274. subkey = 'color'),
  275. size = globalvar.DIALOG_COLOR_SIZE)
  276. color.SetName('GetColour')
  277. self.winId['nviz:light:color'] = color.GetId()
  278. gridSizer.Add(item = color, pos = (3, 2))
  279. boxSizer.Add(item = gridSizer, proportion = 1,
  280. flag = wx.ALL | wx.EXPAND, border = 5)
  281. pageSizer.Add(item = boxSizer, proportion = 0,
  282. flag = wx.EXPAND | wx.ALL,
  283. border = 5)
  284. panel.SetSizer(pageSizer)
  285. return panel
  286. def _createSurfacePage(self, notebook):
  287. """!Create notebook page for surface settings"""
  288. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  289. notebook.AddPage(page = panel,
  290. text = " %s " % _("Surface"))
  291. pageSizer = wx.BoxSizer(wx.VERTICAL)
  292. # draw
  293. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  294. label = " %s " % (_("Draw")))
  295. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  296. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  297. # mode
  298. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  299. label = _("Mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
  300. pos = (0, 0))
  301. mode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
  302. choices = [_("coarse"),
  303. _("fine"),
  304. _("both")])
  305. self.winId['nviz:surface:draw:mode'] = mode.GetId()
  306. mode.SetName('GetSelection')
  307. mode.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
  308. subkey = ['draw', 'mode']))
  309. gridSizer.Add(item = mode, flag = wx.ALIGN_CENTER_VERTICAL,
  310. pos = (0, 1))
  311. # fine
  312. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  313. label = _("Fine mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
  314. pos = (1, 0))
  315. res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-fine'])
  316. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  317. label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
  318. pos = (1, 1))
  319. fine = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  320. initial = res,
  321. min = 1,
  322. max = 100)
  323. self.winId['nviz:surface:draw:res-fine'] = fine.GetId()
  324. gridSizer.Add(item = fine, flag = wx.ALIGN_CENTER_VERTICAL,
  325. pos = (1, 2))
  326. # coarse
  327. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  328. label = _("Coarse mode:")), flag = wx.ALIGN_CENTER_VERTICAL,
  329. pos = (2, 0))
  330. res = UserSettings.Get(group = 'nviz', key = 'surface', subkey = ['draw','res-coarse'])
  331. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  332. label = _("resolution:")), flag = wx.ALIGN_CENTER_VERTICAL,
  333. pos = (2, 1))
  334. coarse = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  335. initial = res,
  336. min = 1,
  337. max = 100)
  338. self.winId['nviz:surface:draw:res-coarse'] = coarse.GetId()
  339. gridSizer.Add(item = coarse, flag = wx.ALIGN_CENTER_VERTICAL,
  340. pos = (2, 2))
  341. #style
  342. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  343. label = _("style:")), flag = wx.ALIGN_CENTER_VERTICAL,
  344. pos = (3, 1))
  345. style = wx.Choice(parent = panel, id = wx.ID_ANY, size = (-1, -1),
  346. choices = [_("wire"),
  347. _("surface")])
  348. self.winId['nviz:surface:draw:style'] = style.GetId()
  349. style.SetName('GetSelection')
  350. style.SetSelection(UserSettings.Get(group = 'nviz', key = 'surface',
  351. subkey = ['draw', 'style']))
  352. self.winId['nviz:surface:draw:style'] = style.GetId()
  353. gridSizer.Add(item = style, flag = wx.ALIGN_CENTER_VERTICAL,
  354. pos = (3, 2))
  355. #wire color
  356. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  357. label = _("wire color:")), flag = wx.ALIGN_CENTER_VERTICAL,
  358. pos = (4, 1))
  359. color = csel.ColourSelect(panel, id = wx.ID_ANY,
  360. colour = UserSettings.Get(group = 'nviz', key = 'surface',
  361. subkey = ['draw', 'wire-color']),
  362. size = globalvar.DIALOG_COLOR_SIZE)
  363. color.SetName('GetColour')
  364. self.winId['nviz:surface:draw:wire-color'] = color.GetId()
  365. gridSizer.Add(item = color, flag = wx.ALIGN_CENTER_VERTICAL,
  366. pos = (4, 2))
  367. boxSizer.Add(item = gridSizer, proportion = 1,
  368. flag = wx.ALL | wx.EXPAND, border = 5)
  369. pageSizer.Add(item = boxSizer, proportion = 0,
  370. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  371. border = 5)
  372. panel.SetSizer(pageSizer)
  373. return panel
  374. def _createVectorPage(self, notebook):
  375. """!Create notebook page for vector settings"""
  376. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  377. notebook.AddPage(page = panel,
  378. text = " %s " % _("Vector"))
  379. pageSizer = wx.BoxSizer(wx.VERTICAL)
  380. # vector lines
  381. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  382. label = " %s " % (_("Vector lines")))
  383. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  384. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 3)
  385. row = 0
  386. # icon size
  387. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  388. label = _("Width:")),
  389. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  390. iwidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  391. initial = 12,
  392. min = 1,
  393. max = 100)
  394. self.winId['nviz:vector:lines:width'] = iwidth.GetId()
  395. iwidth.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
  396. subkey = ['lines', 'width']))
  397. gridSizer.Add(item = iwidth, pos = (row, 1),
  398. flag = wx.ALIGN_CENTER_VERTICAL)
  399. # icon color
  400. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  401. label = _("Color:")),
  402. pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
  403. icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
  404. size = globalvar.DIALOG_COLOR_SIZE)
  405. icolor.SetName('GetColour')
  406. self.winId['nviz:vector:lines:color'] = icolor.GetId()
  407. icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
  408. subkey = ['lines', 'color']))
  409. gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
  410. pos = (row, 5))
  411. boxSizer.Add(item = gridSizer, proportion = 1,
  412. flag = wx.ALL | wx.EXPAND, border = 5)
  413. pageSizer.Add(item = boxSizer, proportion = 0,
  414. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  415. border = 5)
  416. # vector points
  417. box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
  418. label = " %s " % (_("Vector points")))
  419. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  420. gridSizer = wx.GridBagSizer(vgap = 3, hgap = 5)
  421. row = 0
  422. # icon size
  423. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  424. label = _("Size:")),
  425. pos = (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
  426. isize = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (65, -1),
  427. initial = 100,
  428. min = 1,
  429. max = 1e6)
  430. self.winId['nviz:vector:points:size'] = isize.GetId()
  431. isize.SetValue(UserSettings.Get(group = 'nviz', key = 'vector',
  432. subkey = ['points', 'size']))
  433. gridSizer.Add(item = isize, pos = (row, 1),
  434. flag = wx.ALIGN_CENTER_VERTICAL)
  435. # icon symbol
  436. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  437. label = _("Marker:")),
  438. pos = (row, 2), flag = wx.ALIGN_CENTER_VERTICAL)
  439. isym = wx.Choice (parent = panel, id = wx.ID_ANY, size = (100, -1),
  440. choices = UserSettings.Get(group = 'nviz', key = 'vector',
  441. subkey = ['points', 'marker'], internal = True))
  442. isym.SetName("GetSelection")
  443. self.winId['nviz:vector:points:marker'] = isym.GetId()
  444. isym.SetSelection(UserSettings.Get(group = 'nviz', key = 'vector',
  445. subkey = ['points', 'marker']))
  446. gridSizer.Add(item = isym, flag = wx.ALIGN_CENTER_VERTICAL,
  447. pos = (row, 3))
  448. # icon color
  449. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  450. label = _("Color:")),
  451. pos = (row, 4), flag = wx.ALIGN_CENTER_VERTICAL)
  452. icolor = csel.ColourSelect(panel, id = wx.ID_ANY,
  453. size = globalvar.DIALOG_COLOR_SIZE)
  454. icolor.SetName('GetColour')
  455. self.winId['nviz:vector:points:color'] = icolor.GetId()
  456. icolor.SetColour(UserSettings.Get(group = 'nviz', key = 'vector',
  457. subkey = ['points', 'color']))
  458. gridSizer.Add(item = icolor, flag = wx.ALIGN_CENTER_VERTICAL,
  459. pos = (row, 5))
  460. boxSizer.Add(item = gridSizer, proportion = 1,
  461. flag = wx.ALL | wx.EXPAND, border = 5)
  462. pageSizer.Add(item = boxSizer, proportion = 0,
  463. flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  464. border = 5)
  465. panel.SetSizer(pageSizer)
  466. return panel
  467. def OnDefault(self, event):
  468. """!Button 'Set to default' pressed"""
  469. self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
  470. # update widgets
  471. for gks in self.winId.keys():
  472. subkey1 = None
  473. try:
  474. group, key, subkey = gks.split(':')
  475. value = self.settings.Get(group, key, subkey)
  476. except ValueError:
  477. group, key, subkey, subkey1 = gks.split(':')
  478. value = self.settings.Get(group, key, [subkey, subkey1])
  479. if subkey == 'position':
  480. if subkey1 in ('x', 'y'):
  481. value = float(value) * 100
  482. win = self.FindWindowById(self.winId[gks])
  483. if win.GetName() == 'GetSelection':
  484. value = win.SetSelection(value)
  485. else:
  486. value = win.SetValue(value)
  487. def OnApply(self, event):
  488. """Apply Nviz settings for current session"""
  489. for item in self.winId.keys():
  490. try:
  491. group, key, subkey = item.split(':')
  492. subkey1 = None
  493. except ValueError:
  494. group, key, subkey, subkey1 = item.split(':')
  495. id = self.winId[item]
  496. win = self.FindWindowById(id)
  497. if win.GetName() == 'GetSelection':
  498. value = win.GetSelection()
  499. elif win.GetName() == 'GetColour':
  500. value = tuple(win.GetValue())
  501. else:
  502. value = win.GetValue()
  503. if subkey == 'position':
  504. if subkey1 in ('x', 'y'):
  505. value = float(value) / 100
  506. if subkey1:
  507. self.settings.Set(group, value, key, [subkey, subkey1])
  508. else:
  509. self.settings.Set(group, value, key, subkey)
  510. self.toolWin.LoadSettings()
  511. def OnSave(self, event):
  512. """!Save button pressed
  513. Apply changes and save settings to configuration file
  514. """
  515. self.OnApply(None)
  516. fileSettings = {}
  517. UserSettings.ReadSettingsFile(settings = fileSettings)
  518. fileSettings['nviz'] = UserSettings.Get(group = 'nviz')
  519. UserSettings.SaveToFile(fileSettings)
  520. self.parent.goutput.WriteLog(
  521. _('3D view settings saved to file <%s>.') % UserSettings.filePath)
  522. self.Destroy()