preferences.py 29 KB

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