nviz_tools.py 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659
  1. """
  2. @package nviz_tools.py
  3. @brief Nviz tools window
  4. Classes:
  5. - NvizToolWindow
  6. - ViewPositionWindow
  7. (C) 2008-2009 by the GRASS Development Team
  8. This program is free software under the GNU General Public
  9. License (>=v2). Read the file COPYING that comes with GRASS
  10. for details.
  11. @author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
  12. @enhancements by Michael Barton <michael.barton@asu.edu>
  13. """
  14. import os
  15. import sys
  16. import copy
  17. import wx
  18. import wx.lib.colourselect as csel
  19. import globalvar
  20. import gselect
  21. import gcmd
  22. from preferences import globalSettings as UserSettings
  23. from nviz_mapdisp import wxUpdateView as wxUpdateView
  24. from nviz_mapdisp import wxUpdateProperties as wxUpdateProperties
  25. sys.path.append(os.path.join(globalvar.ETCWXDIR, "nviz"))
  26. import grass7_wxnviz as wxnviz
  27. class NvizToolWindow(wx.Frame):
  28. """!Experimental window for Nviz tools
  29. @todo integrate with Map display
  30. """
  31. def __init__(self, parent=None, id=wx.ID_ANY, title=_("3d view tools"),
  32. pos=wx.DefaultPosition, size=wx.DefaultSize,
  33. mapWindow=None,
  34. style=wx.CAPTION|wx.MINIMIZE_BOX|wx.RESIZE_BORDER):
  35. self.parent = parent # MapFrame
  36. self.lmgr = self.parent.GetLayerManager() # GMFrame
  37. self.mapWindow = mapWindow
  38. wx.Frame.__init__(self, parent, id, title, pos, size, style)
  39. #
  40. # icon
  41. #
  42. self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_nviz.ico'), wx.BITMAP_TYPE_ICO))
  43. #
  44. # dialog body
  45. #
  46. mainSizer = wx.BoxSizer(wx.VERTICAL)
  47. self.win = {} # window ids
  48. #
  49. # notebook
  50. #
  51. self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
  52. self.page = {}
  53. self.win['settings'] = {}
  54. self.win['settings']['general'] = {}
  55. # view page
  56. self.viewPos = ""
  57. self.__createViewPage()
  58. self.page['view'] = { 'id' : 0 }
  59. # surface page
  60. size = self.__createSurfacePage()
  61. size = (size[0] + 25, size[0] + 20)
  62. # vector page
  63. self.__createVectorPage()
  64. # volume page
  65. self.__createVolumePage()
  66. # settings page
  67. # self.__createSettingsPage()
  68. # self.page['settings'] = { 'id' : 1 }
  69. self.UpdateSettings()
  70. self.pageChanging = False
  71. self.mapWindow.render['quick'] = False
  72. self.mapWindow.Refresh(False)
  73. mainSizer.Add(item=self.notebook, proportion=1,
  74. flag=wx.EXPAND | wx.ALL, border=5)
  75. #
  76. # bindings
  77. #
  78. self.Bind(wx.EVT_CLOSE, self.OnClose)
  79. self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
  80. #
  81. # layout
  82. #
  83. self.SetSizer(mainSizer)
  84. mainSizer.Fit(self)
  85. # self.SetSize(size) #this produces a size that is consistently too small for the controls
  86. self.Layout()
  87. self.notebook.Update()
  88. self.Update()
  89. self.SetPage('view')
  90. self.CentreOnScreen()
  91. def OnPageChanged(self, event):
  92. new = event.GetSelection()
  93. self.notebook.ChangeSelection(new)
  94. def PostViewEvent(self, zExag=False):
  95. """!Change view settings"""
  96. event = wxUpdateView(zExag=zExag)
  97. wx.PostEvent(self.mapWindow, event)
  98. def __createViewPage(self):
  99. """!Create view settings page"""
  100. panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY)
  101. self.notebook.InsertPage(0, page=panel,
  102. text=" %s " % _("View"),
  103. select=True)
  104. pageSizer = wx.BoxSizer(wx.VERTICAL)
  105. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  106. label=" %s " % (_("Control View")))
  107. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  108. gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
  109. self.win['view'] = {}
  110. # position
  111. posSizer = wx.GridBagSizer(vgap=3, hgap=3)
  112. posSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("W")),
  113. pos=(1, 0), flag=wx.ALIGN_CENTER)
  114. posSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("N")),
  115. pos=(0, 1), flag=wx.ALIGN_CENTER | wx.ALIGN_BOTTOM)
  116. self.viewPos = ViewPositionWindow(panel, id=wx.ID_ANY, size=(175, 175),
  117. mapwindow=self.mapWindow, win=self.win)
  118. self.win['view']['pos'] = self.viewPos.GetId()
  119. posSizer.Add(item=self.viewPos,
  120. pos=(1, 1), flag=wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
  121. posSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("S")),
  122. pos=(2, 1), flag=wx.ALIGN_CENTER | wx.ALIGN_TOP)
  123. posSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("E")),
  124. pos=(1, 2), flag=wx.ALIGN_CENTER)
  125. gridSizer.Add(item=posSizer, pos=(0, 0))
  126. # perspective
  127. # set initial defaults here (or perhaps in a default values file), not in user settings
  128. # range = UserSettings.Get(group='nviz', key='view', subkey='persp', internal=True)
  129. self.CreateControl(panel, dict=self.win['view'], name='persp',
  130. range=(1,100),
  131. bind=(self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
  132. gridSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("Perspective:")),
  133. pos=(1, 0), flag=wx.ALIGN_CENTER)
  134. gridSizer.Add(item=self.FindWindowById(self.win['view']['persp']['slider']), pos=(2, 0))
  135. gridSizer.Add(item=self.FindWindowById(self.win['view']['persp']['spin']), pos=(3, 0),
  136. flag=wx.ALIGN_CENTER)
  137. # twist
  138. # range = UserSettings.Get(group='nviz', key='view', subkey='twist', internal=True)
  139. self.CreateControl(panel, dict=self.win['view'], name='twist',
  140. range=(-180,180),
  141. bind=(self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
  142. gridSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("Twist:")),
  143. pos=(1, 1), flag=wx.ALIGN_CENTER)
  144. gridSizer.Add(item=self.FindWindowById(self.win['view']['twist']['slider']), pos=(2, 1))
  145. gridSizer.Add(item=self.FindWindowById(self.win['view']['twist']['spin']), pos=(3, 1),
  146. flag=wx.ALIGN_CENTER)
  147. # height + z-exag
  148. self.CreateControl(panel, dict=self.win['view'], name='height', sliderHor=False,
  149. range=(0, 1),
  150. bind=(self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
  151. self.CreateControl(panel, dict=self.win['view'], name='z-exag', sliderHor=False,
  152. range=(0, 5),
  153. bind=(self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
  154. self.FindWindowById(self.win['view']['z-exag']['slider']).SetValue(1)
  155. self.FindWindowById(self.win['view']['z-exag']['spin']).SetValue(1)
  156. heightSizer = wx.GridBagSizer(vgap=3, hgap=3)
  157. heightSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("Height:")),
  158. pos=(0, 0), flag=wx.ALIGN_LEFT, span=(1, 2))
  159. heightSizer.Add(item=self.FindWindowById(self.win['view']['height']['slider']),
  160. flag=wx.ALIGN_RIGHT, pos=(1, 0))
  161. heightSizer.Add(item=self.FindWindowById(self.win['view']['height']['spin']),
  162. flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
  163. wx.BOTTOM | wx.RIGHT, pos=(1, 1))
  164. heightSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("Z-exag:")),
  165. pos=(0, 2), flag=wx.ALIGN_LEFT, span=(1, 2))
  166. heightSizer.Add(item=self.FindWindowById(self.win['view']['z-exag']['slider']),
  167. flag=wx.ALIGN_RIGHT, pos=(1, 2))
  168. heightSizer.Add(item=self.FindWindowById(self.win['view']['z-exag']['spin']),
  169. flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.TOP |
  170. wx.BOTTOM | wx.RIGHT, pos=(1, 3))
  171. gridSizer.Add(item=heightSizer, pos=(0, 1), flag=wx.ALIGN_RIGHT)
  172. # view setup + reset
  173. viewSizer = wx.BoxSizer(wx.HORIZONTAL)
  174. viewSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY,
  175. label=_("Look at:")),
  176. flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5)
  177. viewType = wx.Choice (parent=panel, id=wx.ID_ANY, size=(125, -1),
  178. choices = [_("top"),
  179. _("north"),
  180. _("south"),
  181. _("east"),
  182. _("west"),
  183. _("north-west"),
  184. _("north-east"),
  185. _("south-east"),
  186. _("south-west")])
  187. viewType.SetSelection(0)
  188. viewType.Bind(wx.EVT_CHOICE, self.OnLookAt)
  189. # self.win['lookAt'] = viewType.GetId()
  190. viewSizer.Add(item=viewType, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
  191. border=5)
  192. reset = wx.Button(panel, id=wx.ID_ANY, label=_("Reset"))
  193. reset.SetToolTipString(_("Reset to default view"))
  194. # self.win['reset'] = reset.GetId()
  195. reset.Bind(wx.EVT_BUTTON, self.OnResetView)
  196. viewSizer.Add(item=reset, proportion=1,
  197. flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT,
  198. border=5)
  199. gridSizer.AddGrowableCol(3)
  200. gridSizer.Add(item=viewSizer, pos=(4, 0), span=(1, 2),
  201. flag=wx.EXPAND)
  202. # body
  203. # pageSizer.Add(item=gridSizer, proportion=1,
  204. # flag=wx.EXPAND | wx.ALL,
  205. # border=5)
  206. boxSizer.Add(item=gridSizer, proportion=1,
  207. flag=wx.ALL | wx.EXPAND, border=3)
  208. pageSizer.Add(item=boxSizer, proportion=0,
  209. flag=wx.EXPAND | wx.ALL,
  210. border=1)
  211. # background color
  212. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  213. label=" %s " % (_("Image Appearance")))
  214. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  215. gridSizer = wx.GridBagSizer(vgap=1, hgap=3)
  216. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  217. label=_("Background color:")),
  218. pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  219. color = csel.ColourSelect(panel, id=wx.ID_ANY,
  220. colour=(255,255,255))
  221. self.win['settings']['general']['bgcolor'] = color.GetId()
  222. color.Bind(csel.EVT_COLOURSELECT, self.OnBgColor)
  223. gridSizer.Add(item=color, pos=(0, 1))
  224. boxSizer.Add(item=gridSizer, proportion=1,
  225. flag=wx.ALL | wx.EXPAND, border=1)
  226. pageSizer.Add(item=boxSizer, proportion=0,
  227. flag=wx.EXPAND | wx.ALL,
  228. border=1)
  229. #
  230. # buttons
  231. #
  232. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  233. label=" %s " % (_("Saved NVIZ Settings")))
  234. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  235. btnLoad = wx.Button(panel, wx.ID_CANCEL, label=_("Load"))
  236. btnDefault = wx.Button(panel, wx.ID_CANCEL, label=_("Default"))
  237. btnSave = wx.Button(panel, wx.ID_SAVE)
  238. btnLoad.Bind(wx.EVT_BUTTON, self.OnLoad)
  239. btnLoad.SetToolTipString(_("Load and apply settings from user settings file"))
  240. btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
  241. btnDefault.SetToolTipString(_("Restore default settings"))
  242. btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
  243. btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
  244. btnSizer = wx.GridSizer(1, 5, vgap=1, hgap=3)
  245. btnSizer.Add(item=btnDefault, flag=wx.ALIGN_LEFT)
  246. btnSizer.Add((-1, -1), flag=wx.ALIGN_CENTRE)
  247. btnSizer.Add(item=btnLoad, flag=wx.ALIGN_RIGHT)
  248. btnSizer.Add(item=btnSave, flag=wx.ALIGN_RIGHT)
  249. btnSave.SetDefault()
  250. boxSizer.Add(item=btnSizer, proportion=1,
  251. flag=wx.ALL | wx.EXPAND, border=1)
  252. pageSizer.Add(item=boxSizer, proportion=0,
  253. flag=wx.EXPAND | wx.ALL,
  254. border=1)
  255. panel.SetSizer(pageSizer)
  256. return panel.GetBestSize()
  257. def __createSurfacePage(self):
  258. """!Create view settings page"""
  259. panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY)
  260. self.page['surface'] = {}
  261. self.page['surface']['id'] = -1
  262. self.page['surface']['panel'] = panel.GetId()
  263. # panel = scrolled.ScrolledPanel(parent=self.notebook, id=wx.ID_ANY)
  264. # panel.SetupScrolling(scroll_x=True, scroll_y=True)
  265. pageSizer = wx.BoxSizer(wx.VERTICAL)
  266. self.win['surface'] = {}
  267. #
  268. # surface attributes
  269. #
  270. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  271. label=" %s " % (_("Surface attributes")))
  272. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  273. gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
  274. # type
  275. self.win['surface']['attr'] = {}
  276. row = 0
  277. for code, attrb in (('topo', _("Topography")),
  278. ('color', _("Color")),
  279. ('mask', _("Mask")),
  280. ('transp', _("Transparency")),
  281. ('shine', _("Shininess")),
  282. ('emit', _("Emission"))):
  283. self.win['surface'][code] = {}
  284. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  285. label=attrb + ':'),
  286. pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  287. use = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  288. choices = [_("map")])
  289. if code not in ('topo', 'color', 'shine'):
  290. use.Insert(item=_("unset"), pos=0)
  291. self.win['surface'][code]['required'] = False
  292. else:
  293. self.win['surface'][code]['required'] = True
  294. if code != 'mask':
  295. use.Append(item=_('constant'))
  296. self.win['surface'][code]['use'] = use.GetId()
  297. use.Bind(wx.EVT_CHOICE, self.OnMapObjUse)
  298. gridSizer.Add(item=use, flag=wx.ALIGN_CENTER_VERTICAL,
  299. pos=(row, 1))
  300. map = gselect.Select(parent=panel, id=wx.ID_ANY,
  301. # size=globalvar.DIALOG_GSELECT_SIZE,
  302. size=(200, -1),
  303. type="raster")
  304. self.win['surface'][code]['map'] = map.GetId() - 1 # FIXME
  305. map.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
  306. # changing map topography not allowed
  307. if code == 'topo':
  308. map.Enable(False)
  309. gridSizer.Add(item=map, flag=wx.ALIGN_CENTER_VERTICAL,
  310. pos=(row, 2))
  311. if code == 'color':
  312. value = csel.ColourSelect(panel, id=wx.ID_ANY,
  313. colour=(0,0,0))
  314. value.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceMap)
  315. elif code == 'mask':
  316. value = None
  317. else:
  318. value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  319. initial=0)
  320. if code == 'topo':
  321. value.SetRange(minVal=-1e9, maxVal=1e9)
  322. elif code in ('shine', 'transp', 'emit'):
  323. value.SetRange(minVal=0, maxVal=255)
  324. else:
  325. value.SetRange(minVal=0, maxVal=100)
  326. value.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
  327. if value:
  328. self.win['surface'][code]['const'] = value.GetId()
  329. value.Enable(False)
  330. gridSizer.Add(item=value, flag=wx.ALIGN_CENTER_VERTICAL,
  331. pos=(row, 3))
  332. else:
  333. self.win['surface'][code]['const'] = None
  334. self.SetMapObjUseMap(nvizType='surface',
  335. attrb=code) # -> enable map / disable constant
  336. row += 1
  337. boxSizer.Add(item=gridSizer, proportion=1,
  338. flag=wx.ALL | wx.EXPAND, border=3)
  339. pageSizer.Add(item=boxSizer, proportion=0,
  340. flag=wx.EXPAND | wx.ALL,
  341. border=5)
  342. #
  343. # draw
  344. #
  345. self.win['surface']['draw'] = {}
  346. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  347. label=" %s " % (_("Draw")))
  348. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  349. gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  350. gridSizer.AddGrowableCol(6)
  351. # mode
  352. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  353. label=_("Mode:")),
  354. pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  355. mode = wx.Choice (parent=panel, id=wx.ID_ANY, size=(-1, -1),
  356. choices = [_("coarse"),
  357. _("fine"),
  358. _("both")])
  359. mode.SetSelection(0)
  360. mode.SetName("selection")
  361. mode.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
  362. self.win['surface']['draw']['mode'] = mode.GetId()
  363. gridSizer.Add(item=mode, flag=wx.ALIGN_CENTER_VERTICAL,
  364. pos=(0, 1))
  365. # shading
  366. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  367. label=_("Shading:")),
  368. pos=(0, 2), flag=wx.ALIGN_CENTER_VERTICAL)
  369. shade = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  370. choices = [_("flat"),
  371. _("gouraud")])
  372. shade.SetName("selection")
  373. self.win['surface']['draw']['shading'] = shade.GetId()
  374. shade.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
  375. gridSizer.Add(item=shade, flag=wx.ALIGN_CENTER_VERTICAL,
  376. pos=(0, 3))
  377. # set to all
  378. all = wx.Button(panel, id=wx.ID_ANY, label=_("Set to all"))
  379. all.SetToolTipString(_("Use draw settings for all loaded surfaces"))
  380. all.Bind(wx.EVT_BUTTON, self.OnSurfaceModeAll)
  381. gridSizer.Add(item=all, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
  382. pos=(0, 4), span=(1,2), border = 3 )
  383. # resolution coarse
  384. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  385. label=_("Coarse:")),
  386. pos=(1, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  387. resSizer = wx.BoxSizer(wx.HORIZONTAL)
  388. resSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  389. label=_("res.")),
  390. flag=wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
  391. border=3)
  392. resC = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  393. initial=6,
  394. min=1,
  395. max=100)
  396. resC.SetName("value")
  397. resC.SetValue(6)
  398. self.win['surface']['draw']['res-coarse'] = resC.GetId()
  399. resC.Bind(wx.EVT_SPINCTRL, self.OnSurfaceResolution)
  400. resSizer.Add(item=resC, flag=wx.ALL | wx.ALIGN_LEFT |
  401. wx.ALIGN_CENTER_VERTICAL, border=3)
  402. gridSizer.Add(item=resSizer, pos=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL)
  403. # Coarse style
  404. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  405. label=_("style")),
  406. pos=(1, 2), flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
  407. style = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  408. choices = [_("wire"),
  409. _("surface")])
  410. style.SetName("selection")
  411. self.win['surface']['draw']['style'] = style.GetId()
  412. style.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
  413. gridSizer.Add(item=style, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
  414. pos=(1, 3))
  415. # color
  416. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  417. label=_("wire color")),
  418. pos=(1, 4), flag=wx.ALIGN_CENTER_VERTICAL |
  419. wx.ALIGN_RIGHT | wx.LEFT, border=3)
  420. color = csel.ColourSelect(panel, id=wx.ID_ANY)
  421. color.SetColour((136,136,136))
  422. color.SetName("colour")
  423. color.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceWireColor)
  424. self.win['surface']['draw']['wire-color'] = color.GetId()
  425. gridSizer.Add(item=color, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT,
  426. pos=(1, 5))
  427. # resolution fine
  428. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  429. label=_("Fine:")),
  430. pos=(2, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  431. resSizer = wx.BoxSizer(wx.HORIZONTAL)
  432. resSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  433. label=_("res.")),
  434. flag=wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
  435. border=3)
  436. resF = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  437. initial=3,
  438. min=1,
  439. max=100)
  440. resF.SetName("value")
  441. resF.SetValue(3)
  442. self.win['surface']['draw']['res-fine'] = resF.GetId()
  443. resF.Bind(wx.EVT_SPINCTRL, self.OnSurfaceResolution)
  444. resSizer.Add(item=resF, flag=wx.ALL | wx.ALIGN_LEFT |
  445. wx.ALIGN_CENTER_VERTICAL, border=3)
  446. gridSizer.Add(item=resSizer, pos=(2, 1), flag=wx.ALIGN_CENTER_VERTICAL)
  447. boxSizer.Add(item=gridSizer, proportion=1,
  448. flag=wx.ALL | wx.EXPAND, border=3)
  449. pageSizer.Add(item=boxSizer, proportion=0,
  450. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  451. border=5)
  452. #
  453. # mask
  454. #
  455. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  456. label=" %s " % (_("Mask")))
  457. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  458. gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  459. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  460. label=_("Mask zeros:")),
  461. pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  462. elev = wx.CheckBox(parent=panel, id=wx.ID_ANY,
  463. label=_("by elevation"))
  464. elev.Enable(False) # TODO: not implemented yet
  465. gridSizer.Add(item=elev, pos=(0, 1))
  466. color = wx.CheckBox(parent=panel, id=wx.ID_ANY,
  467. label=_("by color"))
  468. color.Enable(False) # TODO: not implemented yet
  469. gridSizer.Add(item=color, pos=(0, 2))
  470. boxSizer.Add(item=gridSizer, proportion=1,
  471. flag=wx.ALL | wx.EXPAND, border=3)
  472. pageSizer.Add(item=boxSizer, proportion=0,
  473. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  474. border=5)
  475. #
  476. # position
  477. #
  478. self.win['surface']['position'] = {}
  479. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  480. label=" %s " % (_("Position")))
  481. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  482. gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  483. # position
  484. self.CreateControl(panel, dict=self.win['surface'], name='position',
  485. range=(-100, 100),
  486. bind=(self.OnSurfacePosition, self.OnSurfacePosition, self.OnSurfacePosition))
  487. axis = wx.Choice (parent=panel, id=wx.ID_ANY, size=(75, -1),
  488. choices = ["X",
  489. "Y",
  490. "Z"])
  491. self.win['surface']['position']['axis'] = axis.GetId()
  492. axis.SetSelection(0)
  493. axis.Bind(wx.EVT_CHOICE, self.OnSurfaceAxis)
  494. pslide = self.FindWindowById(self.win['surface']['position']['slider'])
  495. pspin = self.FindWindowById(self.win['surface']['position']['spin'])
  496. gridSizer.Add(item=axis, flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 0))
  497. gridSizer.Add(item=pslide, flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 1))
  498. gridSizer.Add(item=pspin, flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 2))
  499. boxSizer.Add(item=gridSizer, proportion=1,
  500. flag=wx.ALL | wx.EXPAND, border=3)
  501. box.SetSizer(boxSizer)
  502. box.Layout()
  503. pageSizer.Add(item=boxSizer, proportion=0,
  504. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  505. border=5)
  506. panel.SetSizer(pageSizer)
  507. panel.Layout()
  508. return panel.GetBestSize()
  509. def __createVectorPage(self):
  510. """!Create view settings page"""
  511. panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY)
  512. self.page['vector'] = {}
  513. self.page['vector']['id'] = -1
  514. self.page['vector']['panel'] = panel.GetId()
  515. pageSizer = wx.BoxSizer(wx.VERTICAL)
  516. self.win['vector'] = {}
  517. #
  518. # desc
  519. #
  520. desc = wx.StaticText(parent=panel, id=wx.ID_ANY,
  521. label="")
  522. self.win['vector']['desc'] = desc.GetId()
  523. pageSizer.Add(item=desc, proportion=0,
  524. flag=wx.EXPAND | wx.ALL,
  525. border=10)
  526. #
  527. # vector lines
  528. #
  529. self.win['vector']['lines'] = {}
  530. showLines = wx.CheckBox(parent=panel, id=wx.ID_ANY,
  531. label=_("Show vector lines"))
  532. showLines.SetValue(True)
  533. self.win['vector']['lines']['show'] = showLines.GetId()
  534. showLines.Bind(wx.EVT_CHECKBOX, self.OnVectorShow)
  535. pageSizer.Add(item=showLines, proportion=0,
  536. flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
  537. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  538. label=" %s " % (_("Vector lines")))
  539. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  540. gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  541. # width
  542. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  543. label=_("Line:")),
  544. pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  545. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  546. label=_("width")),
  547. pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL |
  548. wx.ALIGN_RIGHT)
  549. width = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  550. initial=1,
  551. min=1,
  552. max=100)
  553. width.SetValue(1)
  554. self.win['vector']['lines']['width'] = width.GetId()
  555. width.Bind(wx.EVT_SPINCTRL, self.OnVectorLines)
  556. gridSizer.Add(item=width, pos=(0, 2),
  557. flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
  558. # gridSizer.AddGrowableCol(2)
  559. # color
  560. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  561. label=_("color")),
  562. pos=(0, 3), flag=wx.ALIGN_CENTER_VERTICAL |
  563. wx.ALIGN_RIGHT)
  564. color = csel.ColourSelect(panel, id=wx.ID_ANY,
  565. colour=(0,0,0))
  566. self.win['vector']['lines']['color'] = color.GetId()
  567. color.Bind(csel.EVT_COLOURSELECT, self.OnVectorLines)
  568. gridSizer.Add(item=color, pos=(0, 4), flag=wx.ALIGN_CENTER_VERTICAL |
  569. wx.ALIGN_LEFT)
  570. # gridSizer.AddGrowableCol(5)
  571. # display
  572. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  573. label=_("display")),
  574. pos=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL |
  575. wx.ALIGN_RIGHT)
  576. display = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  577. choices = [_("on surface"),
  578. _("flat")])
  579. self.win['vector']['lines']['flat'] = display.GetId()
  580. display.Bind(wx.EVT_CHOICE, self.OnVectorDisplay)
  581. gridSizer.Add(item=display, flag=wx.ALIGN_CENTER_VERTICAL |
  582. wx.ALIGN_LEFT, pos=(1, 2), span=(1,2))
  583. # height
  584. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  585. label=_("Height above surface:")),
  586. pos=(2, 0), flag=wx.ALIGN_CENTER_VERTICAL,
  587. span=(1, 3))
  588. surface = wx.ComboBox(parent=panel, id=wx.ID_ANY, size=(250, -1),
  589. style=wx.CB_SIMPLE | wx.CB_READONLY,
  590. choices=[])
  591. surface.Bind(wx.EVT_COMBOBOX, self.OnVectorSurface)
  592. self.win['vector']['lines']['surface'] = surface.GetId()
  593. gridSizer.Add(item=surface,
  594. pos=(2, 3), span=(1, 6),
  595. flag=wx.ALIGN_CENTER_VERTICAL)
  596. self.CreateControl(panel, dict=self.win['vector']['lines'], name='height', size=300,
  597. range=(0, 1000),
  598. bind=(self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightSpin))
  599. self.FindWindowById(self.win['vector']['lines']['height']['slider']).SetValue(0)
  600. self.FindWindowById(self.win['vector']['lines']['height']['spin']).SetValue(0)
  601. gridSizer.Add(item=self.FindWindowById(self.win['vector']['lines']['height']['slider']),
  602. pos=(3, 0), span=(1, 7))
  603. gridSizer.Add(item=self.FindWindowById(self.win['vector']['lines']['height']['spin']),
  604. pos=(3, 7),
  605. flag=wx.ALIGN_CENTER)
  606. boxSizer.Add(item=gridSizer, proportion=1,
  607. flag=wx.ALL | wx.EXPAND, border=3)
  608. pageSizer.Add(item=boxSizer, proportion=0,
  609. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  610. border=5)
  611. #
  612. # vector points
  613. #
  614. self.win['vector']['points'] = {}
  615. showPoints = wx.CheckBox(parent=panel, id=wx.ID_ANY,
  616. label=_("Show vector points"))
  617. showPoints.SetValue(True)
  618. self.win['vector']['points']['show'] = showPoints.GetId()
  619. showPoints.Bind(wx.EVT_CHECKBOX, self.OnVectorShow)
  620. pageSizer.Add(item=showPoints, proportion=0,
  621. flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
  622. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  623. label=" %s " % (_("Vector points")))
  624. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  625. gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  626. # icon size
  627. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  628. label=_("Icon:")),
  629. pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  630. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  631. label=_("size")),
  632. pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL |
  633. wx.ALIGN_RIGHT)
  634. isize = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  635. initial=1,
  636. min=1,
  637. max=1e6)
  638. isize.SetName('value')
  639. isize.SetValue(100)
  640. self.win['vector']['points']['size'] = isize.GetId()
  641. isize.Bind(wx.EVT_SPINCTRL, self.OnVectorPoints)
  642. isize.Bind(wx.EVT_TEXT, self.OnVectorPoints)
  643. gridSizer.Add(item=isize, pos=(0, 2),
  644. flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
  645. # icon color
  646. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  647. label=_("color")),
  648. pos=(0, 3), flag=wx.ALIGN_CENTER_VERTICAL |
  649. wx.ALIGN_RIGHT)
  650. icolor = csel.ColourSelect(panel, id=wx.ID_ANY)
  651. icolor.SetName("color")
  652. icolor.SetColour((0,0,255))
  653. self.win['vector']['points']['color'] = icolor.GetId()
  654. icolor.Bind(csel.EVT_COLOURSELECT, self.OnVectorPoints)
  655. gridSizer.Add(item=icolor, flag=wx.ALIGN_CENTER_VERTICAL |
  656. wx.ALIGN_LEFT,
  657. pos=(0, 4))
  658. # icon width (does this do anything???)
  659. # gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  660. # label=_("width")),
  661. # pos=(0, 5), flag=wx.ALIGN_CENTER_VERTICAL |
  662. # wx.ALIGN_RIGHT)
  663. # iwidth = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  664. # initial=1,
  665. # min=1,
  666. # max=1e6)
  667. # iwidth.SetName('value')
  668. # iwidth.SetValue(100)
  669. # self.win['vector']['points']['width'] = iwidth.GetId()
  670. # iwidth.Bind(wx.EVT_SPINCTRL, self.OnVectorPoints)
  671. # iwidth.Bind(wx.EVT_TEXT, self.OnVectorPoints)
  672. # gridSizer.Add(item=iwidth, pos=(0, 6),
  673. # flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
  674. # icon symbol
  675. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  676. label=_("symbol")),
  677. pos=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL)
  678. isym = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  679. choices=UserSettings.Get(group='nviz', key='vector',
  680. subkey=['points', 'marker'], internal=True))
  681. isym.SetName("selection")
  682. self.win['vector']['points']['marker'] = isym.GetId()
  683. isym.Bind(wx.EVT_CHOICE, self.OnVectorPoints)
  684. gridSizer.Add(item=isym, flag=wx.ALIGN_CENTER_VERTICAL,
  685. pos=(1, 2), span=(1,2))
  686. # high
  687. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  688. label=_("Height above surface:")),
  689. pos=(2, 0), flag=wx.ALIGN_CENTER_VERTICAL,
  690. span=(1, 3))
  691. surface = wx.ComboBox(parent=panel, id=wx.ID_ANY, size=(250, -1),
  692. style=wx.CB_SIMPLE | wx.CB_READONLY,
  693. choices=[])
  694. surface.Bind(wx.EVT_COMBOBOX, self.OnVectorSurface)
  695. self.win['vector']['points']['surface'] = surface.GetId()
  696. gridSizer.Add(item=surface,
  697. pos=(2, 3), span=(1, 5),
  698. flag=wx.ALIGN_CENTER_VERTICAL)
  699. self.CreateControl(panel, dict=self.win['vector']['points'], name='height', size=300,
  700. range=(0, 1000),
  701. bind=(self.OnVectorHeight, self.OnVectorHeightFull, self.OnVectorHeightSpin))
  702. self.FindWindowById(self.win['vector']['points']['height']['slider']).SetValue(0)
  703. self.FindWindowById(self.win['vector']['points']['height']['spin']).SetValue(0)
  704. gridSizer.Add(item=self.FindWindowById(self.win['vector']['points']['height']['slider']),
  705. pos=(3, 0), span=(1, 7))
  706. gridSizer.Add(item=self.FindWindowById(self.win['vector']['points']['height']['spin']),
  707. pos=(3, 7),
  708. flag=wx.ALIGN_CENTER)
  709. boxSizer.Add(item=gridSizer, proportion=1,
  710. flag=wx.ALL | wx.EXPAND, border=3)
  711. pageSizer.Add(item=boxSizer, proportion=0,
  712. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  713. border=5)
  714. panel.SetSizer(pageSizer)
  715. panel.Layout()
  716. return panel.GetBestSize()
  717. def __createVolumePage(self):
  718. """!Create view settings page"""
  719. panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY)
  720. self.page['volume'] = {}
  721. self.page['volume']['id'] = -1
  722. self.page['volume']['panel'] = panel.GetId()
  723. pageSizer = wx.BoxSizer(wx.VERTICAL)
  724. self.win['volume'] = {}
  725. #
  726. # draw
  727. #
  728. self.win['volume']['draw'] = {}
  729. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  730. label=" %s " % (_("Draw")))
  731. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  732. gridSizer = wx.GridBagSizer(vgap=5, hgap=5)
  733. gridSizer.AddGrowableCol(4)
  734. # mode
  735. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  736. label=_("Mode:")),
  737. pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  738. mode = wx.Choice (parent=panel, id=wx.ID_ANY, size=(150, -1),
  739. choices = [_("isosurfaces"),
  740. _("slides")])
  741. mode.SetSelection(0)
  742. mode.SetName("selection")
  743. # mode.Bind(wx.EVT_CHOICE, self.OnSurfaceMode)
  744. self.win['volume']['draw']['mode'] = mode.GetId()
  745. gridSizer.Add(item=mode, flag=wx.ALIGN_CENTER_VERTICAL,
  746. pos=(0, 1))
  747. # shading
  748. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  749. label=_("Shading:")),
  750. pos=(0, 2), flag=wx.ALIGN_CENTER_VERTICAL)
  751. shade = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  752. choices = [_("flat"),
  753. _("gouraud")])
  754. shade.SetName("selection")
  755. self.win['volume']['draw']['shading'] = shade.GetId()
  756. shade.Bind(wx.EVT_CHOICE, self.OnVolumeIsosurfMode)
  757. gridSizer.Add(item=shade, flag=wx.ALIGN_CENTER_VERTICAL,
  758. pos=(0, 3))
  759. # resolution (mode)
  760. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  761. label=_("Resolution:")),
  762. pos=(0, 4), flag=wx.ALIGN_CENTER_VERTICAL)
  763. resol = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
  764. initial=1,
  765. min=1,
  766. max=100)
  767. resol.SetName("value")
  768. self.win['volume']['draw']['resolution'] = resol.GetId()
  769. resol.Bind(wx.EVT_SPINCTRL, self.OnVolumeIsosurfResolution)
  770. resol.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfResolution)
  771. gridSizer.Add(item=resol, pos=(0, 5))
  772. boxSizer.Add(item=gridSizer, proportion=1,
  773. flag=wx.ALL | wx.EXPAND, border=3)
  774. pageSizer.Add(item=boxSizer, proportion=0,
  775. flag=wx.EXPAND | wx.ALL,
  776. border=5)
  777. #
  778. # manage isosurfaces
  779. #
  780. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  781. label=" %s " % (_("List of isosurfaces")))
  782. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  783. gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
  784. # list
  785. isolevel = wx.CheckListBox(parent=panel, id=wx.ID_ANY,
  786. size=(300, 150))
  787. self.Bind(wx.EVT_CHECKLISTBOX, self.OnVolumeIsosurfCheck, isolevel)
  788. self.Bind(wx.EVT_LISTBOX, self.OnVolumeIsosurfSelect, isolevel)
  789. self.win['volume']['isosurfs'] = isolevel.GetId()
  790. gridSizer.Add(item=isolevel, pos=(0, 0), span=(4, 1))
  791. # buttons (add, delete, move up, move down)
  792. btnAdd = wx.Button(parent=panel, id=wx.ID_ADD)
  793. self.win['volume']['btnIsosurfAdd'] = btnAdd.GetId()
  794. btnAdd.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfAdd)
  795. gridSizer.Add(item=btnAdd,
  796. pos=(0, 1))
  797. btnDelete = wx.Button(parent=panel, id=wx.ID_DELETE)
  798. self.win['volume']['btnIsosurfDelete'] = btnDelete.GetId()
  799. btnDelete.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfDelete)
  800. btnDelete.Enable(False)
  801. gridSizer.Add(item=btnDelete,
  802. pos=(1, 1))
  803. btnMoveUp = wx.Button(parent=panel, id=wx.ID_UP)
  804. self.win['volume']['btnIsosurfMoveUp'] = btnMoveUp.GetId()
  805. btnMoveUp.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfMoveUp)
  806. btnMoveUp.Enable(False)
  807. gridSizer.Add(item=btnMoveUp,
  808. pos=(2, 1))
  809. btnMoveDown = wx.Button(parent=panel, id=wx.ID_DOWN)
  810. self.win['volume']['btnIsosurfMoveDown'] = btnMoveDown.GetId()
  811. btnMoveDown.Bind(wx.EVT_BUTTON, self.OnVolumeIsosurfMoveDown)
  812. btnMoveDown.Enable(False)
  813. gridSizer.Add(item=btnMoveDown,
  814. pos=(3, 1))
  815. boxSizer.Add(item=gridSizer, proportion=1,
  816. flag=wx.ALL | wx.EXPAND, border=3)
  817. pageSizer.Add(item=boxSizer, proportion=0,
  818. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  819. border=5)
  820. #
  821. # isosurface attributes
  822. #
  823. box = wx.StaticBox (parent=panel, id=wx.ID_ANY,
  824. label=" %s " % (_("Isosurface attributes")))
  825. boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  826. gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
  827. self.win['volume']['attr'] = {}
  828. row = 0
  829. for code, attrb in (('topo', _("Topography level")),
  830. ('color', _("Color")),
  831. ('mask', _("Mask")),
  832. ('transp', _("Transparency")),
  833. ('shine', _("Shininess")),
  834. ('emit', _("Emission"))):
  835. self.win['volume'][code] = {}
  836. # label
  837. gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
  838. label=attrb + ':'),
  839. pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
  840. if code != 'topo':
  841. use = wx.Choice (parent=panel, id=wx.ID_ANY, size=(100, -1),
  842. choices = [_("map")])
  843. else:
  844. use = None
  845. # check for required properties
  846. if code not in ('topo', 'color', 'shine'):
  847. use.Insert(item=_("unset"), pos=0)
  848. self.win['volume'][code]['required'] = False
  849. else:
  850. self.win['volume'][code]['required'] = True
  851. if use and code != 'mask':
  852. use.Append(item=_('constant'))
  853. if use:
  854. self.win['volume'][code]['use'] = use.GetId()
  855. use.Bind(wx.EVT_CHOICE, self.OnMapObjUse)
  856. gridSizer.Add(item=use, flag=wx.ALIGN_CENTER_VERTICAL,
  857. pos=(row, 1))
  858. if code != 'topo':
  859. map = gselect.Select(parent=panel, id=wx.ID_ANY,
  860. # size=globalvar.DIALOG_GSELECT_SIZE,
  861. size=(200, -1),
  862. type="grid3")
  863. self.win['volume'][code]['map'] = map.GetId() - 1 # FIXME
  864. map.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
  865. gridSizer.Add(item=map, flag=wx.ALIGN_CENTER_VERTICAL,
  866. pos=(row, 2))
  867. else:
  868. map = None
  869. if code == 'color':
  870. value = csel.ColourSelect(panel, id=wx.ID_ANY,
  871. colour=(0,0,0))
  872. value.SetColour((0,0,0))
  873. value.Bind(csel.EVT_COLOURSELECT, self.OnVolumeIsosurfMap)
  874. elif code == 'mask':
  875. value = None
  876. else:
  877. if code == 'topo':
  878. size = (200, -1)
  879. else:
  880. size = (65, -1)
  881. value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=size,
  882. initial=0)
  883. if code == 'topo':
  884. value.SetRange(minVal=-1e9, maxVal=1e9)
  885. elif code in ('shine', 'transp', 'emit'):
  886. value.SetRange(minVal=0, maxVal=255)
  887. else:
  888. value.SetRange(minVal=0, maxVal=100)
  889. value.Bind(wx.EVT_SPINCTRL, self.OnVolumeIsosurfMap)
  890. value.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
  891. if value:
  892. self.win['volume'][code]['const'] = value.GetId()
  893. if code == 'topo':
  894. gridSizer.Add(item=value, flag=wx.ALIGN_CENTER_VERTICAL,
  895. pos=(row, 2))
  896. else:
  897. value.Enable(False)
  898. gridSizer.Add(item=value, flag=wx.ALIGN_CENTER_VERTICAL,
  899. pos=(row, 3))
  900. else:
  901. self.win['volume'][code]['const'] = None
  902. if code != 'topo':
  903. self.SetMapObjUseMap(nvizType='volume',
  904. attrb=code) # -> enable map / disable constant
  905. row += 1
  906. boxSizer.Add(item=gridSizer, proportion=1,
  907. flag=wx.ALL | wx.EXPAND, border=3)
  908. pageSizer.Add(item=boxSizer, proportion=0,
  909. flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
  910. border=5)
  911. panel.SetSizer(pageSizer)
  912. panel.Layout()
  913. return panel.GetBestSize()
  914. def CreateControl(self, parent, dict, name, range, bind, sliderHor=True, size=200):
  915. """!Add control (Slider + SpinCtrl)"""
  916. dict[name] = {}
  917. if sliderHor:
  918. style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | \
  919. wx.SL_BOTTOM
  920. sizeW = (size, -1)
  921. else:
  922. style = wx.SL_VERTICAL | wx.SL_AUTOTICKS | \
  923. wx.SL_INVERSE
  924. sizeW = (-1, size)
  925. try:
  926. val = self.mapWindow.view[name]['value']
  927. except KeyError:
  928. val=-1
  929. if name == 'z-exag':
  930. val = 1
  931. slider = wx.Slider(parent=parent, id=wx.ID_ANY,
  932. value=val,
  933. minValue=range[0],
  934. maxValue=range[1],
  935. style=style,
  936. size=sizeW)
  937. slider.SetName('slider')
  938. slider.Bind(wx.EVT_SCROLL, bind[0])
  939. slider.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, bind[1])
  940. # slider.Bind(wx.EVT_SCROLL_CHANGED, bind[1]) # this only works in MSW
  941. dict[name]['slider'] = slider.GetId()
  942. slider.SetValue(val)
  943. spin = wx.SpinCtrl(parent=parent, id=wx.ID_ANY, size=(65, -1),
  944. initial=val,
  945. min=range[0],
  946. max=range[1])
  947. spin.SetValue(val)
  948. # spin = wx.SpinButton(parent=parent, id=wx.ID_ANY)
  949. # spin.SetValue (self.mapWindow.view[name]['value'])
  950. # spin.SetRange(self.mapWindow.view[name]['min'],
  951. # self.mapWindow.view[name]['max'])
  952. # no 'changed' event ... (FIXME)
  953. spin.SetName('spin')
  954. spin.Bind(wx.EVT_SPINCTRL, bind[2])
  955. dict[name]['spin'] = spin.GetId()
  956. def UpdateSettings(self):
  957. """!Update view from settings values
  958. stored in self.mapWindow.view dictionary"""
  959. for control in ('height',
  960. 'persp',
  961. 'twist',
  962. 'z-exag'):
  963. for win in self.win['view'][control].itervalues():
  964. if control == 'height':
  965. value = UserSettings.Get(group='nviz', key='view',
  966. subkey=['height', 'value'], internal=True)
  967. else:
  968. value = self.mapWindow.view[control]['value']
  969. self.FindWindowById(win).SetValue(value)
  970. x = self.mapWindow.view['pos']['x']
  971. y = self.mapWindow.view['pos']['y']
  972. self.viewPos.UpdatePos(x, y)
  973. self.FindWindowById(self.win['view']['pos']).Draw()
  974. self.FindWindowById(self.win['view']['pos']).Refresh(False)
  975. bgcolor = self.FindWindowById(self.win['settings']['general']['bgcolor']).GetColour()
  976. self.OnBgColor(event=bgcolor)
  977. self.Update()
  978. self.mapWindow.Refresh(eraseBackground=False)
  979. self.mapWindow.render['quick'] = False
  980. self.mapWindow.Refresh(False)
  981. def __GetWindowName(self, dict, id):
  982. for name in dict.iterkeys():
  983. if type(dict[name]) is type({}):
  984. for win in dict[name].itervalues():
  985. if win == id:
  986. return name
  987. else:
  988. if dict[name] == id:
  989. return name
  990. return None
  991. def OnViewChange(self, event):
  992. """!Change view, render in quick mode"""
  993. # find control
  994. winName = self.__GetWindowName(self.win['view'], event.GetId())
  995. if not winName:
  996. return
  997. if winName == 'height':
  998. view = self.mapWindow.iview # internal
  999. else:
  1000. view = self.mapWindow.view
  1001. if winName == 'z-exag' and event.GetInt() >= 0:
  1002. self.PostViewEvent(zExag = True)
  1003. else:
  1004. self.PostViewEvent(zExag = False)
  1005. view[winName]['value'] = event.GetInt()
  1006. for win in self.win['view'][winName].itervalues():
  1007. self.FindWindowById(win).SetValue(view[winName]['value'])
  1008. self.mapWindow.render['quick'] = True
  1009. self.mapWindow.Refresh(False)
  1010. def OnViewChanged(self, event):
  1011. """!View changed, render in full resolution"""
  1012. self.mapWindow.render['quick'] = False
  1013. self.mapWindow.Refresh(False)
  1014. self.UpdateSettings()
  1015. def OnViewChangedSpin(self, event):
  1016. """!View changed, render in full resolution"""
  1017. # TODO: use step value instead
  1018. self.OnViewChange(event)
  1019. self.OnViewChanged(None)
  1020. self.Update()
  1021. def OnResetView(self, event):
  1022. """!Reset to default view (view page)"""
  1023. self.mapWindow.ResetView()
  1024. self.UpdateSettings()
  1025. self.mapWindow.Refresh(False)
  1026. def OnLookAt(self, event):
  1027. """!Look at (view page)"""
  1028. sel = event.GetSelection()
  1029. if sel == 0: # top
  1030. self.mapWindow.view['pos']['x'] = 0.5
  1031. self.mapWindow.view['pos']['y'] = 0.5
  1032. elif sel == 1: # north
  1033. self.mapWindow.view['pos']['x'] = 0.5
  1034. self.mapWindow.view['pos']['y'] = 0.0
  1035. elif sel == 2: # south
  1036. self.mapWindow.view['pos']['x'] = 0.5
  1037. self.mapWindow.view['pos']['y'] = 1.0
  1038. elif sel == 3: # east
  1039. self.mapWindow.view['pos']['x'] = 1.0
  1040. self.mapWindow.view['pos']['y'] = 0.5
  1041. elif sel == 4: # west
  1042. self.mapWindow.view['pos']['x'] = 0.0
  1043. self.mapWindow.view['pos']['y'] = 0.5
  1044. elif sel == 5: # north-west
  1045. self.mapWindow.view['pos']['x'] = 0.0
  1046. self.mapWindow.view['pos']['y'] = 0.0
  1047. elif sel == 6: # north-east
  1048. self.mapWindow.view['pos']['x'] = 1.0
  1049. self.mapWindow.view['pos']['y'] = 0.0
  1050. elif sel == 7: # south-east
  1051. self.mapWindow.view['pos']['x'] = 1.0
  1052. self.mapWindow.view['pos']['y'] = 1.0
  1053. elif sel == 8: # south-west
  1054. self.mapWindow.view['pos']['x'] = 0.0
  1055. self.mapWindow.view['pos']['y'] = 1.0
  1056. self.PostViewEvent(zExag=True)
  1057. self.UpdateSettings()
  1058. self.mapWindow.Refresh(False)
  1059. def OnDefault(self, event):
  1060. """!Restore default settings"""
  1061. settings = copy.deepcopy(UserSettings.GetDefaultSettings()['nviz'])
  1062. UserSettings.Set(group='nviz',
  1063. value=settings)
  1064. for subgroup, key in settings.iteritems(): # view, surface, vector...
  1065. for subkey, value in key.iteritems():
  1066. for subvalue in value.keys():
  1067. if subvalue == 'step':
  1068. continue
  1069. else:
  1070. defsetting = value[subvalue]
  1071. if subgroup == 'view':
  1072. for viewkey, viewitem in self.mapWindow.view[subkey].iteritems():
  1073. if viewkey == subvalue:
  1074. self.mapWindow.view[subkey][viewkey] = defsetting
  1075. else:
  1076. continue
  1077. elif subgroup == 'settings' and type(defsetting) in [tuple, list]:
  1078. defsetting = tuple(defsetting)
  1079. self.FindWindowById(self.win[subgroup][subkey][subvalue]).SetColour(defsetting)
  1080. else:
  1081. continue
  1082. # should default reset all values or just view (as it does now)?
  1083. # for otherkey, otheritem in self.win[subgroup][subkey].iteritems():
  1084. # if type(otheritem) == dict:
  1085. # for endkey, enditem in otheritem.iteritems():
  1086. # if endkey == subvalue:
  1087. # paramwin = self.FindWindowById(enditem)
  1088. # else:
  1089. # continue
  1090. # else:
  1091. # if otherkey == subvalue:
  1092. # paramwin = self.FindWindowById(otheritem)
  1093. # else:
  1094. # continue
  1095. # if type(insetting) in [tuple, list]:
  1096. # inseting = tuple(insetting)
  1097. # paramwin.SetColour(insetting)
  1098. # else:
  1099. # try:
  1100. # paramwin.SetValue(insetting)
  1101. # except:
  1102. # try:
  1103. # paramwin.SetStringSelection(insetting)
  1104. # except:
  1105. # continue
  1106. self.UpdateSettings()
  1107. self.FindWindowById(self.win['view']['pos']).Draw()
  1108. self.FindWindowById(self.win['view']['pos']).Refresh(False)
  1109. self.mapWindow.render['quick'] = False
  1110. self.mapWindow.Refresh(False)
  1111. event.Skip()
  1112. def OnLoad(self, event):
  1113. """!Apply button pressed"""
  1114. self.LoadSettings()
  1115. if event:
  1116. event.Skip()
  1117. def LoadSettings(self):
  1118. """!Load saved Nviz settings and apply to current session"""
  1119. UserSettings.ReadSettingsFile()
  1120. settings = copy.deepcopy(UserSettings.Get(group='nviz'))
  1121. for subgroup, key in settings.iteritems(): # view, surface, vector...
  1122. for subkey, value in key.iteritems():
  1123. for subvalue in value.keys():
  1124. if subvalue == 'step':
  1125. continue
  1126. else:
  1127. insetting = value[subvalue]
  1128. if subgroup == 'view':
  1129. for viewkey, viewitem in self.mapWindow.view[subkey].iteritems():
  1130. if viewkey == subvalue:
  1131. self.mapWindow.view[subkey][viewkey] = insetting
  1132. else:
  1133. continue
  1134. else:
  1135. for otherkey, otheritem in self.win[subgroup][subkey].iteritems():
  1136. if type(otheritem) == dict:
  1137. for endkey, enditem in otheritem.iteritems():
  1138. if endkey == subvalue:
  1139. paramwin = self.FindWindowById(enditem)
  1140. else:
  1141. continue
  1142. else:
  1143. if otherkey == subvalue:
  1144. paramwin = self.FindWindowById(otheritem)
  1145. else:
  1146. continue
  1147. if type(insetting) in [tuple, list] and len(insetting) > 2:
  1148. insetting = tuple(insetting)
  1149. paramwin.SetColour(insetting)
  1150. else:
  1151. try:
  1152. paramwin.SetValue(insetting)
  1153. except:
  1154. try:
  1155. paramwin.SetStringSelection(insetting)
  1156. except:
  1157. continue
  1158. self.UpdateSettings()
  1159. self.FindWindowById(self.win['view']['pos']).Draw()
  1160. self.FindWindowById(self.win['view']['pos']).Refresh(False)
  1161. self.mapWindow.render['quick'] = False
  1162. self.mapWindow.Refresh(False)
  1163. def OnSave(self, event):
  1164. """!Save button pressed
  1165. Save settings to configuration file
  1166. """
  1167. fileSettings = {}
  1168. UserSettings.ReadSettingsFile(settings=fileSettings)
  1169. self.UpdateSettings()
  1170. nvsettings = UserSettings.Get(group='nviz')
  1171. for subgroup, key in nvsettings.iteritems(): # view, surface, vector...
  1172. for subkey, value in key.iteritems():
  1173. if subkey == 'height': continue
  1174. for subvalue in value.keys():
  1175. if subvalue == 'step':
  1176. #no way to change steps for sliders or spinctrls on non-MSW systems
  1177. nvsettings[subgroup][subkey][subvalue] = 1
  1178. else:
  1179. if subgroup == 'view':
  1180. nvsettings[subgroup][subkey][subvalue] = self.mapWindow.view[subkey][subvalue]
  1181. elif subvalue == 'map':
  1182. if subkey == 'shine':
  1183. nvsettings[subgroup][subkey][subvalue] = False
  1184. if subkey == 'color':
  1185. nvsettings[subgroup][subkey][subvalue] = True
  1186. else:
  1187. for otherkey, otheritem in self.win[subgroup][subkey].iteritems():
  1188. if type(otheritem) == dict:
  1189. for endkey, enditem in otheritem.iteritems():
  1190. if endkey == subvalue:
  1191. if self.FindWindowById(enditem).GetClassName() == 'wxChoice':
  1192. outsetting = self.FindWindowById(enditem).GetSelection()
  1193. else:
  1194. try:
  1195. outsetting = self.FindWindowById(enditem).GetColour()
  1196. outsetting = str(outsetting.Red())+':'+str(outsetting.Green())+':'+str(outsetting.Blue())
  1197. except:
  1198. try:
  1199. outsetting = self.FindWindowById(enditem).GetValue()
  1200. except:
  1201. try:
  1202. outsetting = self.FindWindowById(enditem).GetString()
  1203. except:
  1204. outsetting = ''
  1205. if (type(outsetting) == list or type(outsetting) == tuple) and len(outsetting) > 2:
  1206. outsetting = str(outsetting[0])+':'+str(outsetting[1])+':'+str(outsetting[2])
  1207. nvsettings[subgroup][subkey][subvalue][endkey] = outsetting
  1208. else:
  1209. if otherkey == subvalue:
  1210. if self.FindWindowById(otheritem).GetClassName() == 'wxChoice':
  1211. outsetting = self.FindWindowById(otheritem).GetSelection()
  1212. else:
  1213. try:
  1214. outsetting = self.FindWindowById(otheritem).GetColour()
  1215. outsetting = str(outsetting.Red())+':'+str(outsetting.Green())+':'+str(outsetting.Blue())
  1216. except:
  1217. try:
  1218. outsetting = self.FindWindowById(otheritem).GetValue()
  1219. except:
  1220. try:
  1221. outsetting = self.FindWindowById(enditem).GetString()
  1222. except:
  1223. outsetting = ''
  1224. if (type(outsetting) == list or type(outsetting) == tuple) and len(outsetting) > 2:
  1225. outsetting = str(outsetting[0])+':'+str(outsetting[1])+':'+str(outsetting[2])
  1226. nvsettings[subgroup][subkey][subvalue] = outsetting
  1227. UserSettings.Set(group='nviz', value=nvsettings)
  1228. file = UserSettings.SaveToFile()
  1229. self.lmgr.goutput.WriteLog(_('Nviz settings saved to file <%s>.') % file)
  1230. def OnBgColor(self, event):
  1231. """!Background color changed"""
  1232. try:
  1233. color = event.GetValue()
  1234. except:
  1235. color = event
  1236. if type(color) != wx._gdi.Colour: return
  1237. color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
  1238. self.mapWindow.nvizClass.SetBgColor(str(color))
  1239. if self.parent.statusbarWin['render'].IsChecked():
  1240. self.mapWindow.Refresh(False)
  1241. def OnClose(self, event):
  1242. """!Close button pressed
  1243. Close dialog
  1244. """
  1245. self.Hide()
  1246. def OnMapObjUse(self, event):
  1247. """!Set surface attribute -- use -- map/constant"""
  1248. if not self.mapWindow.init:
  1249. return
  1250. wx.Yield()
  1251. # find attribute row
  1252. attrb = self.__GetWindowName(self.win['surface'], event.GetId())
  1253. if not attrb:
  1254. attrb = self.__GetWindowName(self.win['volume'], event.GetId())
  1255. nvizType = 'volume'
  1256. else:
  1257. nvizType = 'surface'
  1258. selection = event.GetSelection()
  1259. if self.win[nvizType][attrb]['required']: # no 'unset'
  1260. selection += 1
  1261. if selection == 0: # unset
  1262. useMap = None
  1263. value = ''
  1264. elif selection == 1: # map
  1265. useMap = True
  1266. value = self.FindWindowById(self.win[nvizType][attrb]['map']).GetValue()
  1267. elif selection == 2: # constant
  1268. useMap = False
  1269. if attrb == 'color':
  1270. value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetColour()
  1271. value = self._getColorString(value)
  1272. else:
  1273. value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetValue()
  1274. self.SetMapObjUseMap(nvizType=nvizType,
  1275. attrb=attrb, map=useMap)
  1276. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1277. if nvizType == 'surface':
  1278. data[nvizType]['attribute'][attrb] = { 'map' : useMap,
  1279. 'value' : str(value),
  1280. 'update' : None }
  1281. else: # volume / isosurface
  1282. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1283. id = list.GetSelection()
  1284. data[nvizType]['isosurface'][id][attrb] = { 'map' : useMap,
  1285. 'value' : str(value),
  1286. 'update' : None }
  1287. # update properties
  1288. event = wxUpdateProperties(data=data)
  1289. wx.PostEvent(self.mapWindow, event)
  1290. if self.parent.statusbarWin['render'].IsChecked():
  1291. self.mapWindow.Refresh(False)
  1292. def SetMapObjUseMap(self, nvizType, attrb, map=None):
  1293. """!Update dialog widgets when attribute type changed"""
  1294. if attrb in ('topo', 'color', 'shine'):
  1295. incSel = -1 # decrement selection (no 'unset')
  1296. else:
  1297. incSel = 0
  1298. if map is True: # map
  1299. if attrb != 'topo': # changing map topography not allowed
  1300. # not sure why, but here must be disabled both ids, should be fixed!
  1301. self.FindWindowById(self.win[nvizType][attrb]['map'] + 1).Enable(True)
  1302. if self.win[nvizType][attrb]['const']:
  1303. self.FindWindowById(self.win[nvizType][attrb]['const']).Enable(False)
  1304. self.FindWindowById(self.win[nvizType][attrb]['use']).SetSelection(1 + incSel)
  1305. elif map is False: # const
  1306. self.FindWindowById(self.win[nvizType][attrb]['map'] + 1).Enable(False)
  1307. if self.win[nvizType][attrb]['const']:
  1308. self.FindWindowById(self.win[nvizType][attrb]['const']).Enable(True)
  1309. self.FindWindowById(self.win[nvizType][attrb]['use']).SetSelection(2 + incSel)
  1310. else: # unset
  1311. self.FindWindowById(self.win[nvizType][attrb]['map'] + 1).Enable(False)
  1312. if self.win[nvizType][attrb]['const']:
  1313. self.FindWindowById(self.win[nvizType][attrb]['const']).Enable(False)
  1314. self.FindWindowById(self.win[nvizType][attrb]['use']).SetSelection(0)
  1315. def OnSurfaceMap(self, event):
  1316. """!Set surface attribute"""
  1317. self.SetMapObjAttrb(nvizType='surface', winId=event.GetId())
  1318. def SetMapObjAttrb(self, nvizType, winId):
  1319. """!Set map object (surface/isosurface) attribute (map/constant)"""
  1320. if not self.mapWindow.init:
  1321. return
  1322. attrb = self.__GetWindowName(self.win[nvizType], winId)
  1323. if not attrb:
  1324. return
  1325. if nvizType == 'volume' and attrb == 'topo':
  1326. return
  1327. selection = self.FindWindowById(self.win[nvizType][attrb]['use']).GetSelection()
  1328. if self.win[nvizType][attrb]['required']:
  1329. selection += 1
  1330. if selection == 0: # unset
  1331. useMap = None
  1332. value = ''
  1333. elif selection == 1: # map
  1334. value = self.FindWindowById(self.win[nvizType][attrb]['map']).GetValue()
  1335. useMap = True
  1336. else: # constant
  1337. if attrb == 'color':
  1338. value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetColour()
  1339. # tuple to string
  1340. value = self._getColorString(value)
  1341. else:
  1342. value = self.FindWindowById(self.win[nvizType][attrb]['const']).GetValue()
  1343. useMap = False
  1344. if not self.pageChanging:
  1345. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1346. if nvizType == 'surface':
  1347. data[nvizType]['attribute'][attrb] = { 'map' : useMap,
  1348. 'value' : str(value),
  1349. 'update' : None }
  1350. else: # volume / isosurface
  1351. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1352. id = list.GetSelection()
  1353. data[nvizType]['isosurface'][id][attrb] = { 'map' : useMap,
  1354. 'value' : str(value),
  1355. 'update' : None }
  1356. # update properties
  1357. event = wxUpdateProperties(data=data)
  1358. wx.PostEvent(self.mapWindow, event)
  1359. if self.parent.statusbarWin['render'].IsChecked():
  1360. self.mapWindow.Refresh(False)
  1361. def OnSurfaceResolution(self, event):
  1362. """!Draw resolution changed"""
  1363. self.SetSurfaceResolution()
  1364. if apply and self.parent.statusbarWin['render'].IsChecked():
  1365. self.mapWindow.Refresh(False)
  1366. def SetSurfaceResolution(self):
  1367. """!Set draw resolution"""
  1368. coarse = self.FindWindowById(self.win['surface']['draw']['res-coarse']).GetValue()
  1369. fine = self.FindWindowById(self.win['surface']['draw']['res-fine']).GetValue()
  1370. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1371. data['surface']['draw']['resolution'] = { 'coarse' : coarse,
  1372. 'fine' : fine,
  1373. 'update' : None }
  1374. # update properties
  1375. event = wxUpdateProperties(data=data)
  1376. wx.PostEvent(self.mapWindow, event)
  1377. def SetSurfaceMode(self):
  1378. """!Set draw mode
  1379. @param apply allow auto-rendering
  1380. """
  1381. mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
  1382. if mode == 0: # coarse
  1383. self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
  1384. self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
  1385. elif mode == 1: # fine
  1386. self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
  1387. self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
  1388. else: # both
  1389. self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
  1390. self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
  1391. style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
  1392. shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
  1393. value, desc = self.mapWindow.nvizDefault.GetDrawMode(mode, style, shade)
  1394. return value, desc
  1395. def OnSurfaceMode(self, event):
  1396. """!Set draw mode"""
  1397. value, desc = self.SetSurfaceMode()
  1398. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1399. data['surface']['draw']['mode'] = { 'value' : value,
  1400. 'desc' : desc,
  1401. 'update' : None }
  1402. # update properties
  1403. event = wxUpdateProperties(data=data)
  1404. wx.PostEvent(self.mapWindow, event)
  1405. if apply and self.parent.statusbarWin['render'].IsChecked():
  1406. self.mapWindow.Refresh(False)
  1407. def OnSurfaceModeAll(self, event):
  1408. """!Set draw mode (including wire color) for all loaded surfaces"""
  1409. value, desc = self.SetSurfaceMode()
  1410. coarse = self.FindWindowById(self.win['surface']['draw']['res-coarse']).GetValue()
  1411. fine = self.FindWindowById(self.win['surface']['draw']['res-fine']).GetValue()
  1412. color = self.FindWindowById(self.win['surface']['draw']['wire-color']).GetColour()
  1413. cvalue = self._getColorString(color)
  1414. for name in self.mapWindow.GetLayerNames(type='raster'):
  1415. data = self.mapWindow.GetLayerData(type='raster', name=name)
  1416. if not data:
  1417. continue # shouldy no happen
  1418. data['surface']['draw']['mode'] = { 'value' : value,
  1419. 'desc' : desc,
  1420. 'update' : None }
  1421. data['surface']['draw']['resolution'] = { 'coarse' : coarse,
  1422. 'fine' : fine,
  1423. 'update' : None }
  1424. data['surface']['draw']['wire-color'] = { 'value' : cvalue,
  1425. 'update' : None }
  1426. # update properties
  1427. event = wxUpdateProperties(data=data)
  1428. wx.PostEvent(self.mapWindow, event)
  1429. if apply and self.parent.statusbarWin['render'].IsChecked():
  1430. self.mapWindow.Refresh(False)
  1431. def _getColorString(self, color):
  1432. """!Set wire color"""
  1433. return str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
  1434. def OnSurfaceWireColor(self, event):
  1435. """!Set wire color"""
  1436. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1437. value = self._getColorString(event.GetValue())
  1438. data['surface']['draw']['wire-color'] = { 'value' : value,
  1439. 'update' : None }
  1440. # update properties
  1441. event = wxUpdateProperties(data=data)
  1442. wx.PostEvent(self.mapWindow, event)
  1443. if self.parent.statusbarWin['render'].IsChecked():
  1444. self.mapWindow.Refresh(False)
  1445. def OnSurfaceAxis(self, event):
  1446. """!Surface position, axis changed"""
  1447. mapLayer = self.mapWindow.GetSelectedLayer()
  1448. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1449. id = data['surface']['object']['id']
  1450. axis = self.FindWindowById(self.win['surface']['position']['axis']).GetSelection()
  1451. slider = self.FindWindowById(self.win['surface']['position']['slider'])
  1452. spin = self.FindWindowById(self.win['surface']['position']['spin'])
  1453. x, y, z = self.mapWindow.nvizClass.GetSurfacePosition(id)
  1454. if axis == 0: # x
  1455. slider.SetValue(x)
  1456. spin.SetValue(x)
  1457. elif axis == 1: # y
  1458. slider.SetValue(y)
  1459. spin.SetValue(y)
  1460. else: # z
  1461. slider.SetValue(z)
  1462. spin.SetValue(z)
  1463. def OnSurfacePosition(self, event):
  1464. """!Surface position"""
  1465. winName = self.__GetWindowName(self.win['surface'], event.GetId())
  1466. if not winName:
  1467. return
  1468. axis = self.FindWindowById(self.win['surface']['position']['axis']).GetSelection()
  1469. value = event.GetInt()
  1470. for win in self.win['surface']['position'].itervalues():
  1471. if win == self.win['surface']['position']['axis']:
  1472. continue
  1473. else:
  1474. self.FindWindowById(win).SetValue(value)
  1475. mapLayer = self.mapWindow.GetSelectedLayer()
  1476. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1477. id = data['surface']['object']['id']
  1478. x, y, z = self.mapWindow.nvizClass.GetSurfacePosition(id)
  1479. if axis == 0: # x
  1480. x = value
  1481. elif axis == 1: # y
  1482. y = value
  1483. else: # z
  1484. z = value
  1485. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1486. data['surface']['position']['x'] = x
  1487. data['surface']['position']['y'] = y
  1488. data['surface']['position']['z'] = z
  1489. data['surface']['position']['update'] = None
  1490. # update properties
  1491. event = wxUpdateProperties(data=data)
  1492. wx.PostEvent(self.mapWindow, event)
  1493. if self.parent.statusbarWin['render'].IsChecked():
  1494. self.mapWindow.Refresh(False)
  1495. # self.UpdatePage('surface')
  1496. def UpdateVectorShow(self, vecType, enabled):
  1497. """!Enable/disable lines/points widgets
  1498. @param vecType vector type (lines, points)
  1499. """
  1500. if vecType != 'lines' and vecType != 'points':
  1501. return False
  1502. for win in self.win['vector'][vecType].keys():
  1503. if win == 'show':
  1504. continue
  1505. if type(self.win['vector'][vecType][win]) == type({}):
  1506. for swin in self.win['vector'][vecType][win].keys():
  1507. if enabled:
  1508. self.FindWindowById(self.win['vector'][vecType][win][swin]).Enable(True)
  1509. else:
  1510. self.FindWindowById(self.win['vector'][vecType][win][swin]).Enable(False)
  1511. else:
  1512. if enabled:
  1513. self.FindWindowById(self.win['vector'][vecType][win]).Enable(True)
  1514. else:
  1515. self.FindWindowById(self.win['vector'][vecType][win]).Enable(False)
  1516. return True
  1517. def OnVectorShow(self, event):
  1518. """!Show vector lines/points"""
  1519. winId = event.GetId()
  1520. if winId == self.win['vector']['lines']['show']:
  1521. vecType = 'lines'
  1522. else: # points
  1523. vecType = 'points'
  1524. checked = event.IsChecked()
  1525. item = self.mapWindow.GetSelectedLayer(type='item')
  1526. data = self.mapWindow.GetSelectedLayer(type='nviz')['vector']
  1527. if checked:
  1528. self.mapWindow.LoadVector(item, (vecType,))
  1529. else:
  1530. self.mapWindow.UnloadVector(item, (vecType,))
  1531. self.UpdateVectorShow(vecType, checked)
  1532. if checked:
  1533. try:
  1534. id = data[vecType]['object']['id']
  1535. except KeyError:
  1536. id = -1
  1537. if id > 0:
  1538. self.mapWindow.SetMapObjProperties(item, id, vecType)
  1539. # update properties
  1540. event = wxUpdateProperties(data=data)
  1541. wx.PostEvent(self.mapWindow, event)
  1542. if self.parent.statusbarWin['render'].IsChecked():
  1543. self.mapWindow.Refresh(False)
  1544. event.Skip()
  1545. def OnVectorDisplay(self, event):
  1546. """!Display vector lines on surface/flat"""
  1547. rasters = self.mapWindow.GetLayerNames('raster')
  1548. if event.GetSelection() == 0: # surface
  1549. if len(rasters) < 1:
  1550. self.FindWindowById(self.win['vector']['lines']['surface']).Enable(False)
  1551. self.FindWindowById(self.win['vector']['lines']['flat']).SetSelection(1)
  1552. return
  1553. self.FindWindowById(self.win['vector']['lines']['surface']).Enable(True)
  1554. # set first found surface
  1555. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1556. data['vector']['lines']['mode']['surface'] = rasters[0]
  1557. self.FindWindowById(self.win['vector']['lines']['surface']).SetStringSelection( \
  1558. rasters[0])
  1559. else: # flat
  1560. self.FindWindowById(self.win['vector']['lines']['surface']).Enable(False)
  1561. self.OnVectorLines(event)
  1562. event.Skip()
  1563. def OnVectorLines(self, event):
  1564. """!Set vector lines mode, apply changes if auto-rendering is enabled"""
  1565. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1566. width = self.FindWindowById(self.win['vector']['lines']['width']).GetValue()
  1567. mode = {}
  1568. if self.FindWindowById(self.win['vector']['lines']['flat']).GetSelection() == 0:
  1569. mode['type'] = 'surface'
  1570. mode['surface'] = self.FindWindowById(self.win['vector']['lines']['surface']).GetValue()
  1571. mode['update'] = None
  1572. else:
  1573. mode['type'] = 'flat'
  1574. for attrb in ('width', 'mode'):
  1575. data['vector']['lines'][attrb]['update'] = None
  1576. data['vector']['lines']['width']['value'] = width
  1577. data['vector']['lines']['mode']['value'] = mode
  1578. color = self.FindWindowById(self.win['vector']['lines']['color']).GetColour()
  1579. if type(color) != wx._gdi.Colour:
  1580. pass #color picker not yet instantiated
  1581. else:
  1582. color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
  1583. data['vector']['lines']['color']['update'] = None
  1584. data['vector']['lines']['color']['value'] = color
  1585. # update properties
  1586. event = wxUpdateProperties(data=data)
  1587. wx.PostEvent(self.mapWindow, event)
  1588. if self.parent.statusbarWin['render'].IsChecked():
  1589. self.mapWindow.Refresh(False)
  1590. def OnVectorHeight(self, event):
  1591. value = event.GetInt()
  1592. id = event.GetId()
  1593. if id == self.win['vector']['lines']['height']['spin'] or \
  1594. id == self.win['vector']['lines']['height']['slider']:
  1595. vtype = 'lines'
  1596. else:
  1597. vtype = 'points'
  1598. if type(event) == type(wx.ScrollEvent()):
  1599. # slider
  1600. win = self.FindWindowById(self.win['vector'][vtype]['height']['spin'])
  1601. else:
  1602. # spin
  1603. win = self.FindWindowById(self.win['vector'][vtype]['height']['slider'])
  1604. win.SetValue(value)
  1605. data = self.mapWindow.GetSelectedLayer(type='nviz')['vector'][vtype]
  1606. data['height'] = { 'value' : value,
  1607. 'update' : None }
  1608. # update properties
  1609. event = wxUpdateProperties(data=data)
  1610. wx.PostEvent(self.mapWindow, event)
  1611. self.mapWindow.render['quick'] = True
  1612. self.mapWindow.render['v' + vtype] = True
  1613. self.mapWindow.Refresh(False)
  1614. event.Skip()
  1615. def OnVectorHeightFull(self, event):
  1616. """!Vector height changed, render in full resolution"""
  1617. self.OnVectorHeight(event)
  1618. self.OnVectorSurface(event)
  1619. id = event.GetId()
  1620. if id == self.win['vector']['lines']['height']['spin'] or \
  1621. id == self.win['vector']['lines']['height']['slider']:
  1622. vtype = 'lines'
  1623. else:
  1624. vtype = 'points'
  1625. self.mapWindow.render['quick'] = False
  1626. self.mapWindow.render['v' + vtype] = False
  1627. self.mapWindow.Refresh(False)
  1628. def OnVectorHeightSpin(self, event):
  1629. """!Vector height changed, render in full resolution"""
  1630. # TODO: use step value instead
  1631. # self.OnVectorHeight(event)
  1632. self.OnVectorHeightFull(event)
  1633. def OnVectorSurface(self, event):
  1634. """!Reference surface for vector map (lines/points)"""
  1635. id = event.GetId()
  1636. if id == self.win['vector']['lines']['surface']:
  1637. vtype = 'lines'
  1638. else:
  1639. vtype = 'points'
  1640. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1641. data['vector'][vtype]['mode']['surface'] = { 'value' : event.GetString(),
  1642. 'update' : None }
  1643. # update properties
  1644. event = wxUpdateProperties(data=data)
  1645. wx.PostEvent(self.mapWindow, event)
  1646. if self.parent.statusbarWin['render'].IsChecked():
  1647. self.mapWindow.Refresh(False)
  1648. def OnVectorPoints(self, event):
  1649. """!Set vector points mode, apply changes if auto-rendering is enabled"""
  1650. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1651. size = self.FindWindowById(self.win['vector']['points']['size']).GetValue()
  1652. marker = self.FindWindowById(self.win['vector']['points']['marker']).GetSelection()
  1653. # width = self.FindWindowById(self.win['vector']['points']['width']).GetValue()
  1654. for attrb in ('size', 'marker'):
  1655. data['vector']['points'][attrb]['update'] = None
  1656. data['vector']['points']['size']['value'] = size
  1657. # data['vector']['points']['width']['value'] = width
  1658. data['vector']['points']['marker']['value'] = marker
  1659. color = self.FindWindowById(self.win['vector']['points']['color']).GetColour()
  1660. if type(color) != wx._gdi.Colour:
  1661. pass #color picker not yet instantiated
  1662. else:
  1663. color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
  1664. data['vector']['points']['color']['update'] = None
  1665. data['vector']['points']['color']['value'] = color
  1666. # update properties
  1667. event = wxUpdateProperties(data=data)
  1668. wx.PostEvent(self.mapWindow, event)
  1669. if self.parent.statusbarWin['render'].IsChecked():
  1670. self.mapWindow.Refresh(False)
  1671. def UpdateIsosurfButtons(self, list):
  1672. """!Enable/disable buttons 'add', 'delete',
  1673. 'move up', 'move down'"""
  1674. nitems = list.GetCount()
  1675. add = self.parent.FindWindowById(self.win['volume']['btnIsosurfAdd'])
  1676. delete = self.parent.FindWindowById(self.win['volume']['btnIsosurfDelete'])
  1677. moveDown = self.parent.FindWindowById(self.win['volume']['btnIsosurfMoveDown'])
  1678. moveUp = self.parent.FindWindowById(self.win['volume']['btnIsosurfMoveUp'])
  1679. if nitems >= wxnviz.MAX_ISOSURFS:
  1680. # disable add button on max
  1681. add.Enable(False)
  1682. else:
  1683. add.Enable(True)
  1684. if nitems < 1:
  1685. # disable 'delete' if only one item in the lis
  1686. delete.Enable(False)
  1687. else:
  1688. delete.Enable(True)
  1689. if list.GetSelection() >= nitems - 1:
  1690. # disable 'move-down' if last
  1691. moveDown.Enable(False)
  1692. else:
  1693. moveDown.Enable(True)
  1694. if list.GetSelection() < 1:
  1695. # disable 'move-up' if first
  1696. moveUp.Enable(False)
  1697. else:
  1698. moveUp.Enable(True)
  1699. def OnVolumeIsosurfMode(self, event):
  1700. """!Set isosurface draw mode"""
  1701. self.SetIsosurfaceMode(event.GetSelection())
  1702. def SetIsosurfaceMode(self, selection):
  1703. """!Set isosurface draw mode"""
  1704. layer = self.mapWindow.GetSelectedLayer()
  1705. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1706. id = data['object']['id']
  1707. mode = 0
  1708. if selection == 0:
  1709. mode |= wxnviz.DM_FLAT
  1710. else:
  1711. mode |= wxnviz.DM_GOURAUD
  1712. self.mapWindow.nvizClass.SetIsosurfaceMode(id, mode)
  1713. if self.parent.statusbarWin['render'].IsChecked():
  1714. self.mapWindow.Refresh(False)
  1715. def OnVolumeIsosurfResolution(self, event):
  1716. """!Set isosurface draw resolution"""
  1717. self.SetIsosurfaceResolution(event.GetInt())
  1718. def SetIsosurfaceResolution(self, res):
  1719. """!Set isosurface draw resolution"""
  1720. layer = self.mapWindow.GetSelectedLayer()
  1721. try:
  1722. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1723. except:
  1724. # no volume layer
  1725. return
  1726. id = data['object']['id']
  1727. self.mapWindow.nvizClass.SetIsosurfaceRes(id, res)
  1728. if self.parent.statusbarWin['render'].IsChecked():
  1729. self.mapWindow.Refresh(False)
  1730. def OnVolumeIsosurfMap(self, event):
  1731. """!Set surface attribute"""
  1732. self.SetMapObjAttrb(nvizType='volume', winId=event.GetId())
  1733. def OnVolumeIsosurfCheck(self, event):
  1734. """!Isosurface checked (->load) or unchecked (->unload)"""
  1735. index = event.GetSelection()
  1736. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1737. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1738. id = data['object']['id']
  1739. isosurfId = event.GetSelection()
  1740. if list.IsChecked(index):
  1741. self.mapWindow.nvizClass.SetIsosurfaceTransp(id, isosurfId, False, "0")
  1742. else:
  1743. # disable -> make transparent
  1744. self.mapWindow.nvizClass.SetIsosurfaceTransp(id, isosurfId, False, "255")
  1745. if self.parent.statusbarWin['render'].IsChecked():
  1746. self.mapWindow.Refresh(False)
  1747. def OnVolumeIsosurfSelect(self, event):
  1748. """!Isosurface item selected"""
  1749. winUp = self.FindWindowById(self.win['volume']['btnIsosurfMoveUp'])
  1750. winDown = self.FindWindowById(self.win['volume']['btnIsosurfMoveDown'])
  1751. selection = event.GetSelection()
  1752. if selection == 0:
  1753. winUp.Enable(False)
  1754. if not winDown.IsEnabled():
  1755. winDown.Enable()
  1756. elif selection == self.FindWindowById(event.GetId()).GetCount() - 1:
  1757. winDown.Enable(False)
  1758. if not winUp.IsEnabled():
  1759. winUp.Enable()
  1760. else:
  1761. if not winDown.IsEnabled():
  1762. winDown.Enable()
  1763. if not winUp.IsEnabled():
  1764. winUp.Enable()
  1765. # update dialog
  1766. layer = self.mapWindow.GetSelectedLayer()
  1767. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']['isosurface'][selection]
  1768. self.UpdateVolumeIsosurfPage(layer, data)
  1769. def OnVolumeIsosurfAdd(self, event):
  1770. """!Add new isosurface to the list"""
  1771. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1772. level = self.FindWindowById(self.win['volume']['topo']['const']).GetValue()
  1773. sel = list.GetSelection()
  1774. if sel < 0 or sel >= list.GetCount() - 1:
  1775. item = list.Append(item="%s %s" % (_("Level"), str(level)))
  1776. else:
  1777. list.Insert(item="%s %s" % (_("Level"), str(level)),
  1778. pos=sel+1) # append
  1779. item = sel + 1
  1780. list.Check(item)
  1781. list.SetSelection(item)
  1782. layer = self.mapWindow.GetSelectedLayer()
  1783. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1784. id = data['object']['id']
  1785. # collect properties
  1786. isosurfData = {}
  1787. for attrb in ('topo', 'color', 'mask',
  1788. 'transp', 'shine', 'emit'):
  1789. if attrb == 'topo':
  1790. isosurfData[attrb] = {}
  1791. win = self.FindWindowById(self.win['volume'][attrb]['const'])
  1792. isosurfData[attrb]['value'] = win.GetValue()
  1793. else:
  1794. uwin = self.FindWindowById(self.win['volume'][attrb]['use'])
  1795. sel = uwin.GetSelection()
  1796. if self.win['volume'][attrb]['required']:
  1797. sel += 1
  1798. if sel == 0: # unset
  1799. continue
  1800. isosurfData[attrb] = {}
  1801. if sel == 1: # map
  1802. isosurfData[attrb]['map'] = True
  1803. vwin = self.FindWindowById(self.win['volume'][attrb]['map'])
  1804. value = vwin.GetValue()
  1805. else: # const
  1806. isosurfData[attrb]['map'] = False
  1807. vwin = self.FindWindowById(self.win['volume'][attrb]['const'])
  1808. if vwin.GetName() == "color":
  1809. value = self._getColorString(vwin.GetValue())
  1810. else:
  1811. value = vwin.GetValue()
  1812. isosurfData[attrb]['value'] = value
  1813. data['isosurface'].insert(item, isosurfData)
  1814. # add isosurface
  1815. self.mapWindow.nvizClass.AddIsosurface(id, level)
  1816. # use by default 3d raster map for color
  1817. self.mapWindow.nvizClass.SetIsosurfaceColor(id, item, True, str(layer.name))
  1818. # update buttons
  1819. self.UpdateIsosurfButtons(list)
  1820. if self.parent.statusbarWin['render'].IsChecked():
  1821. self.mapWindow.Refresh(False)
  1822. event.Skip()
  1823. def OnVolumeIsosurfDelete(self, event):
  1824. """!Remove isosurface from list"""
  1825. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1826. # remove item from list
  1827. isosurfId = list.GetSelection()
  1828. list.Delete(isosurfId)
  1829. # select last item
  1830. if list.GetCount() > 0:
  1831. list.SetSelection(list.GetCount()-1)
  1832. layer = self.mapWindow.GetSelectedLayer()
  1833. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1834. id = data['object']['id']
  1835. # delete isosurface
  1836. del data['isosurface'][isosurfId]
  1837. self.mapWindow.nvizClass.DeleteIsosurface(id, isosurfId)
  1838. # update buttons
  1839. self.UpdateIsosurfButtons(list)
  1840. if self.parent.statusbarWin['render'].IsChecked():
  1841. self.mapWindow.Refresh(False)
  1842. event.Skip()
  1843. def OnVolumeIsosurfMoveUp(self, event):
  1844. """!Move isosurface up in the list"""
  1845. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1846. sel = list.GetSelection()
  1847. if sel < 1:
  1848. return # this should not happen
  1849. layer = self.mapWindow.GetSelectedLayer()
  1850. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1851. id = data['object']['id']
  1852. # move item up
  1853. text = list.GetStringSelection()
  1854. list.Insert(item=text, pos=sel-1)
  1855. list.Check(sel-1)
  1856. list.SetSelection(sel-1)
  1857. list.Delete(sel+1)
  1858. data['isosurface'].insert(sel-1, data['isosurface'][sel])
  1859. del data['isosurface'][sel+1]
  1860. self.mapWindow.nvizClass.MoveIsosurface(id, sel, True)
  1861. # update buttons
  1862. self.UpdateIsosurfButtons(list)
  1863. if self.parent.statusbarWin['render'].IsChecked():
  1864. self.mapWindow.Refresh(False)
  1865. event.Skip()
  1866. def OnVolumeIsosurfMoveDown(self, event):
  1867. """!Move isosurface dowm in the list"""
  1868. list = self.FindWindowById(self.win['volume']['isosurfs'])
  1869. sel = list.GetSelection()
  1870. if sel >= list.GetCount() - 1:
  1871. return # this should not happen
  1872. layer = self.mapWindow.GetSelectedLayer()
  1873. data = self.mapWindow.GetSelectedLayer(type='nviz')['volume']
  1874. id = data['object']['id']
  1875. # move item up
  1876. text = list.GetStringSelection()
  1877. list.Insert(item=text, pos=sel+2)
  1878. list.Check(sel+2)
  1879. list.SetSelection(sel+2)
  1880. list.Delete(sel)
  1881. data['isosurface'].insert(sel+2, data['isosurface'][sel])
  1882. del data['isosurface'][sel]
  1883. self.mapWindow.nvizClass.MoveIsosurface(id, sel, False)
  1884. # update buttons
  1885. self.UpdateIsosurfButtons(list)
  1886. if self.parent.statusbarWin['render'].IsChecked():
  1887. self.mapWindow.Refresh(False)
  1888. event.Skip()
  1889. def UpdatePage(self, pageId):
  1890. """!Update dialog (selected page)"""
  1891. self.pageChanging = True
  1892. layer = self.mapWindow.GetSelectedLayer()
  1893. data = self.mapWindow.GetSelectedLayer(type='nviz')
  1894. if pageId == 'view':
  1895. self.SetPage('view')
  1896. # max = self.mapWindow.view['z-exag']['value'] * 10 #this value is essentially null
  1897. hmin = self.mapWindow.iview['height']['min']
  1898. hmax = self.mapWindow.iview['height']['max']
  1899. hval = int(0.4 * (hmax - hmin)) + hmin
  1900. for control in ('spin', 'slider'):
  1901. # self.FindWindowById(self.win['view']['z-exag'][control]).SetRange(0,
  1902. # max)
  1903. self.FindWindowById(self.win['view']['height'][control]).SetRange(hmin,
  1904. hmax)
  1905. self.FindWindowById(self.win['view']['height'][control]).SetValue(hval)
  1906. elif pageId in ('surface', 'vector', 'volume'):
  1907. current_page = self.notebook.GetSelection()
  1908. if self.notebook.GetSelection() != self.page[pageId]['id']:
  1909. for page in ('surface', 'vector', 'volume'):
  1910. if self.page[page]['id'] > -1:
  1911. self.notebook.RemovePage(self.page[page]['id'])
  1912. self.page[page]['id'] = -1
  1913. oldpanel = wx.FindWindowById(self.page[page]['panel'])
  1914. oldpanel.Hide()
  1915. self.page[pageId]['id'] = 1
  1916. # self.page['settings']['id'] = 2
  1917. panel = wx.FindWindowById(self.page[pageId]['panel'])
  1918. self.notebook.InsertPage(n=self.page[pageId]['id'],
  1919. page=panel,
  1920. text=" %s " % _("Layer properties"),
  1921. select=True)
  1922. self.notebook.ChangeSelection(current_page)
  1923. if pageId == 'surface':
  1924. self.UpdateSurfacePage(layer, data['surface'])
  1925. elif pageId == 'vector':
  1926. self.UpdateVectorPage(layer, data['vector'])
  1927. elif pageId == 'volume':
  1928. self.UpdateVectorPage(layer, data['vector'])
  1929. # self.notebook.Update()
  1930. self.pageChanging = False
  1931. def UpdateSurfacePage(self, layer, data):
  1932. #
  1933. # attributes
  1934. #
  1935. for attr in ('topo', 'color'): # required
  1936. if layer and layer.type == 'raster':
  1937. self.FindWindowById(self.win['surface'][attr]['map']).SetValue(layer.name)
  1938. else:
  1939. self.FindWindowById(self.win['surface'][attr]['map']).SetValue('')
  1940. self.SetMapObjUseMap(nvizType='surface',
  1941. attrb=attr, map=True) # -> map
  1942. if data['attribute'].has_key('color'):
  1943. value = data['attribute']['color']['value']
  1944. if data['attribute']['color']['map']:
  1945. self.FindWindowById(self.win['surface']['color']['map']).SetValue(value)
  1946. else: # constant
  1947. color = map(int, value.split(':'))
  1948. self.FindWindowById(self.win['surface']['color']['const']).SetColour(color)
  1949. self.SetMapObjUseMap(nvizType='surface',
  1950. attrb=attr, map=data['attribute']['color']['map'])
  1951. self.SetMapObjUseMap(nvizType='surface',
  1952. attrb='shine', map=data['attribute']['shine']['map'])
  1953. value = data['attribute']['shine']['value']
  1954. if data['attribute']['shine']['map']:
  1955. self.FindWindowById(self.win['surface']['shine']['map']).SetValue(value)
  1956. else:
  1957. self.FindWindowById(self.win['surface']['shine']['const']).SetValue(value)
  1958. #
  1959. # draw
  1960. #
  1961. for control, dict in data['draw'].iteritems():
  1962. if control == 'all': # skip 'all' property
  1963. continue
  1964. if control == 'resolution':
  1965. self.FindWindowById(self.win['surface']['draw']['res-coarse']).SetValue(dict['coarse'])
  1966. self.FindWindowById(self.win['surface']['draw']['res-fine']).SetValue(dict['fine'])
  1967. continue
  1968. if control == 'mode':
  1969. if dict['desc']['mode'] == 'coarse':
  1970. self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(0)
  1971. elif dict['desc']['mode'] == 'fine':
  1972. self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(1)
  1973. else: # both
  1974. self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(2)
  1975. if dict['desc']['style'] == 'wire':
  1976. self.FindWindowById(self.win['surface']['draw']['style']).SetSelection(0)
  1977. else: # surface
  1978. self.FindWindowById(self.win['surface']['draw']['style']).SetSelection(1)
  1979. if dict['desc']['shading'] == 'flat':
  1980. self.FindWindowById(self.win['surface']['draw']['shading']).SetSelection(0)
  1981. else: # gouraud
  1982. self.FindWindowById(self.win['surface']['draw']['shading']).SetSelection(1)
  1983. continue
  1984. value = dict['value']
  1985. win = self.FindWindowById(self.win['surface']['draw'][control])
  1986. name = win.GetName()
  1987. if name == "selection":
  1988. win.SetSelection(value)
  1989. elif name == "colour":
  1990. color = map(int, value.split(':'))
  1991. win.SetColour(color)
  1992. else:
  1993. win.SetValue(value)
  1994. # enable/disable res widget + set draw mode
  1995. self.SetSurfaceMode()
  1996. color = self.FindWindowById(self.win['surface']['draw']['wire-color'])
  1997. def UpdateVectorPage(self, layer, data):
  1998. vInfo = gcmd.RunCommand('v.info',
  1999. parent = self,
  2000. read = True,
  2001. flags = 't',
  2002. map = layer.name)
  2003. if not vInfo:
  2004. return
  2005. npoints = nprimitives = 0
  2006. for line in vInfo.splitlines():
  2007. key, value = line.split('=')
  2008. if key == 'map3d':
  2009. mapIs3D = int(value)
  2010. elif key == 'points':
  2011. npoints = int(value)
  2012. nprimitives = npoints
  2013. elif key in ('lines',
  2014. 'boundaries',
  2015. 'centroids',
  2016. 'faces',
  2017. 'kernels'):
  2018. nprimitives += int(value)
  2019. if mapIs3D:
  2020. desc = _("Vector map <%s> is 3D") % layer.name
  2021. enable = False
  2022. else:
  2023. desc = _("Vector map <%s> is 2D") % layer.name
  2024. enable = True
  2025. desc += " - " + _("%(primitives)d primitives (%(points)d points)") % \
  2026. { 'primitives' : nprimitives, 'points' : npoints }
  2027. self.FindWindowById(self.win['vector']['lines']['flat']).Enable(enable)
  2028. for v in ('lines', 'points'):
  2029. self.FindWindowById(self.win['vector'][v]['surface']).Enable(enable)
  2030. self.FindWindowById(self.win['vector'][v]['height']['slider']).Enable(enable)
  2031. self.FindWindowById(self.win['vector'][v]['height']['spin']).Enable(enable)
  2032. self.FindWindowById(self.win['vector']['desc']).SetLabel(desc)
  2033. #
  2034. # lines
  2035. #
  2036. showLines = self.FindWindowById(self.win['vector']['lines']['show'])
  2037. if data['lines'].has_key('object'):
  2038. showLines.SetValue(True)
  2039. else:
  2040. showLines.SetValue(False)
  2041. if nprimitives - npoints > 0:
  2042. showLines.Enable(True)
  2043. else:
  2044. showLines.Enable(False)
  2045. self.UpdateVectorShow('lines',
  2046. showLines.IsChecked())
  2047. width = self.FindWindowById(self.win['vector']['lines']['width'])
  2048. width.SetValue(data['lines']['width']['value'])
  2049. color = self.FindWindowById(self.win['vector']['lines']['color'])
  2050. color.SetValue(map(int, data['lines']['color']['value'].split(':')))
  2051. for vtype in ('lines', 'points'):
  2052. if vtype == 'lines':
  2053. display = self.FindWindowById(self.win['vector']['lines']['flat'])
  2054. if data[vtype]['mode']['type'] == 'flat':
  2055. display.SetSelection(1)
  2056. else:
  2057. display.SetSelection(0)
  2058. if data[vtype]['mode']['type'] == 'surface':
  2059. rasters = self.mapWindow.GetLayerNames('raster')
  2060. surface = self.FindWindowById(self.win['vector'][vtype]['surface'])
  2061. surface.SetItems(rasters)
  2062. if len(rasters) > 0:
  2063. try:
  2064. surface.SetStringSelection(data[vtype]['mode']['surface'])
  2065. except:
  2066. pass
  2067. for type in ('slider', 'spin'):
  2068. win = self.FindWindowById(self.win['vector']['lines']['height'][type])
  2069. win.SetValue(data['lines']['height']['value'])
  2070. #
  2071. # points
  2072. #
  2073. showPoints = self.FindWindowById(self.win['vector']['points']['show'])
  2074. if data['points'].has_key('object'):
  2075. showPoints.SetValue(True)
  2076. else:
  2077. showPoints.SetValue(False)
  2078. if npoints > 0:
  2079. showPoints.Enable(True)
  2080. else:
  2081. showPoints.Enable(False)
  2082. self.UpdateVectorShow('points',
  2083. showPoints.IsChecked())
  2084. # size, width, marker, color
  2085. for prop in ('size', 'marker', 'color'):
  2086. win = self.FindWindowById(self.win['vector']['points'][prop])
  2087. name = win.GetName()
  2088. if name == 'selection':
  2089. win.SetSelection(data['points'][prop]['value'])
  2090. elif name == 'color':
  2091. color = map(int, data['points'][prop]['value'].split(':'))
  2092. win.SetValue(color)
  2093. else:
  2094. win.SetValue(data['points'][prop]['value'])
  2095. # height
  2096. for type in ('slider', 'spin'):
  2097. win = self.FindWindowById(self.win['vector']['points']['height'][type])
  2098. win.SetValue(data['points']['height']['value'])
  2099. def UpdateVolumePage(self, layer, data):
  2100. """!Update volume layer properties page"""
  2101. list = self.FindWindowById(self.win['volume']['isosurfs'])
  2102. #
  2103. # draw
  2104. #
  2105. for control, dict in data['draw'].iteritems():
  2106. if control == 'all': # skip 'all' property
  2107. continue
  2108. win = self.FindWindowById(self.win['volume']['draw'][control])
  2109. if control == 'shading':
  2110. if data['draw']['shading']['desc'] == 'flat':
  2111. value = 0
  2112. else:
  2113. value = 1
  2114. else:
  2115. value = dict['value']
  2116. if win.GetName() == "selection":
  2117. win.SetSelection(value)
  2118. else:
  2119. win.SetValue(value)
  2120. self.SetIsosurfaceMode(data['draw']['shading']['value'])
  2121. self.SetIsosurfaceResolution(data['draw']['resolution']['value'])
  2122. self.UpdateVolumeIsosurfPage(layer, data['attribute'])
  2123. def UpdateVolumeIsosurfPage(self, layer, data):
  2124. """!Update dialog -- isosurface attributes"""
  2125. #
  2126. # isosurface attributes
  2127. #
  2128. for attrb in ('topo', 'color', 'mask',
  2129. 'transp', 'shine', 'emit'):
  2130. # check required first
  2131. if attrb == 'topo':
  2132. self.FindWindowById(self.win['volume'][attrb]['const']).SetValue(0)
  2133. continue
  2134. if attrb == 'color':
  2135. if layer and layer.type == '3d-raster':
  2136. self.FindWindowById(self.win['volume'][attrb]['map']).SetValue(layer.name)
  2137. else:
  2138. self.FindWindowById(self.win['volume'][attrb]['map']).SetValue('')
  2139. self.SetMapObjUseMap(nvizType='volume',
  2140. attrb=attrb, map=True) # -> map
  2141. continue
  2142. # skip empty attributes
  2143. if not data.has_key(attrb):
  2144. continue
  2145. value = data[attrb]['value']
  2146. if attrb == 'color':
  2147. if data[attrb]['map']:
  2148. self.FindWindowById(self.win['volume'][attrb]['map']).SetValue(value)
  2149. else: # constant
  2150. color = map(int, value.split(':'))
  2151. self.FindWindowById(self.win['volume'][attrb]['const']).SetColour(color)
  2152. else:
  2153. if data[attrb]['map']:
  2154. win = self.FindWindowById(self.win['volume'][attrb]['map'])
  2155. else:
  2156. win = self.FindWindowById(self.win['volume'][attrb]['const'])
  2157. win.SetValue(value)
  2158. self.SetMapObjUseMap(nvizType='volume',
  2159. attrb=attrb, map=data[attrb]['map'])
  2160. def SetPage(self, name):
  2161. """!Get named page"""
  2162. self.notebook.SetSelection(self.page[name]['id'])
  2163. class ViewPositionWindow(wx.Window):
  2164. """!Position control window (for NvizToolWindow)"""
  2165. def __init__(self, parent, id, mapwindow, win,
  2166. pos=wx.DefaultPosition,
  2167. size=wx.DefaultSize):
  2168. self.mapWindow = mapwindow
  2169. self.toolwin = parent.GetGrandParent()
  2170. wx.Window.__init__(self, parent, id, pos, size)
  2171. self.SetBackgroundColour("WHITE")
  2172. self.pdc = wx.PseudoDC()
  2173. self.pdc.SetBrush(wx.Brush(colour='dark green', style=wx.SOLID))
  2174. self.pdc.SetPen(wx.Pen(colour='dark green', width=2, style=wx.SOLID))
  2175. self.Draw()
  2176. self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
  2177. self.Bind(wx.EVT_PAINT, self.OnPaint)
  2178. # self.Bind(wx.EVT_MOTION, self.OnMouse)
  2179. self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
  2180. def Draw(self, pos=None):
  2181. w, h = self.GetClientSize()
  2182. if pos is None:
  2183. x = self.mapWindow.view['pos']['x']
  2184. y = self.mapWindow.view['pos']['y']
  2185. x = x * w
  2186. y = y * h
  2187. else:
  2188. x, y = pos
  2189. self.pdc.Clear()
  2190. self.pdc.BeginDrawing()
  2191. self.pdc.DrawLine(w / 2, h / 2, x, y)
  2192. self.pdc.DrawCircle(x, y, 5)
  2193. self.pdc.EndDrawing()
  2194. def OnPaint(self, event):
  2195. dc = wx.BufferedPaintDC(self)
  2196. dc.SetBackground(wx.Brush("White"))
  2197. dc.Clear()
  2198. self.PrepareDC(dc)
  2199. self.pdc.DrawToDC(dc)
  2200. def OnMouse(self, event):
  2201. if event.LeftIsDown():
  2202. x, y = event.GetPosition()
  2203. self.mapWindow.view['x'] = x
  2204. self.mapWindow.view['y'] = y
  2205. self.Draw(pos=(x, y))
  2206. self.Refresh(False)
  2207. w, h = self.GetClientSize()
  2208. x = float(x) / w
  2209. y = float(y) / h
  2210. self.UpdatePos(x, y)
  2211. self.mapWindow.render['quick'] = True
  2212. elif event.LeftUp():
  2213. self.mapWindow.render['quick'] = False
  2214. self.mapWindow.Refresh(eraseBackground=False)
  2215. event.Skip()
  2216. def UpdatePos(self, xcoord, ycoord):
  2217. if xcoord >= 0 and xcoord <= 1.0:
  2218. self.mapWindow.view['pos']['x'] = xcoord
  2219. if ycoord >= 0 and ycoord <= 1.0:
  2220. self.mapWindow.view['pos']['y'] = ycoord
  2221. event = wxUpdateView(zExag=True)
  2222. wx.PostEvent(self.mapWindow, event)