nviz_preferences.py 29 KB

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