preferences.py 29 KB

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