nviz_tools.py 109 KB

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