wizard.py 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. """
  2. @package rlisetup.py
  3. @brief GUI per r.li.setup module
  4. Classes:
  5. - RLiSetupFrame (first frame to show existing conf file and choose some
  6. operation)
  7. - RLIWizard (the main wizard)
  8. - FirstPage (first page of wizard, choose name of conf file, raster, vector,
  9. sampling region)
  10. - Keybord (page to insert region areas from keybord)
  11. - SamplingAreas (define sampling area)
  12. - SummaryPage (show choosen options)
  13. (C) 2011 by the GRASS Development Team
  14. This program is free software under the GNU General Public License
  15. (>=v2). Read the file COPYING that comes with GRASS for details.
  16. @author Luca Delucchi <lucadeluge gmail com>
  17. """
  18. import sys
  19. import os
  20. wxbase = os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython')
  21. if wxbase not in sys.path:
  22. sys.path.append(wxbase)
  23. import wx
  24. import wx.wizard as wiz
  25. import wx.lib.scrolledpanel as scrolled
  26. from gui_core import gselect
  27. from core import gcmd
  28. from core.utils import _
  29. from location_wizard.wizard import TitledPage as TitledPage
  30. from rlisetup.functions import checkValue, retRLiPath
  31. from rlisetup.sampling_frame import RLiSetupMapPanel
  32. from grass.script import core as grass
  33. from grass.script import raster as grast
  34. #@NOTE: r.li.setup writes in the settings file with
  35. ## r.li.windows.tcl:
  36. #exec echo "SAMPLINGFRAME $per_x|$per_y|$per_rl|$per_cl" >> $env(TMP).set
  37. class RLIWizard(object):
  38. """
  39. Start wizard here and finish wizard here
  40. """
  41. def __init__(self, parent):
  42. self.parent = parent
  43. self.wizard = wiz.Wizard(parent=parent, id=wx.ID_ANY,
  44. title=_("Create new configuration file for " \
  45. "r.li modules"))
  46. self.rlipath = retRLiPath()
  47. #pages
  48. self.startpage = FirstPage(self.wizard, self)
  49. self.drawsampleframepage = DrawSampleFramePage(self.wizard, self)
  50. self.keyboardpage = KeybordPage(self.wizard, self)
  51. self.samplingareapage = SamplingAreasPage(self.wizard, self)
  52. self.summarypage = SummaryPage(self.wizard, self)
  53. self.units = SampleUnitsKeyPage(self.wizard, self)
  54. self.moving = MovingWindows(self.wizard, self)
  55. #order of pages
  56. self.startpage.SetNext(self.samplingareapage)
  57. self.keyboardpage.SetPrev(self.startpage)
  58. self.keyboardpage.SetNext(self.samplingareapage)
  59. self.drawsampleframepage.SetNext(self.samplingareapage)
  60. self.drawsampleframepage.SetPrev(self.startpage)
  61. self.samplingareapage.SetPrev(self.startpage)
  62. self.samplingareapage.SetNext(self.summarypage)
  63. self.units.SetPrev(self.samplingareapage)
  64. self.units.SetNext(self.summarypage)
  65. self.moving.SetPrev(self.samplingareapage)
  66. self.moving.SetNext(self.summarypage)
  67. self.summarypage.SetPrev(self.samplingareapage)
  68. #layout
  69. self.startpage.DoLayout()
  70. self.drawsampleframepage.DoLayout()
  71. self.keyboardpage.DoLayout()
  72. self.samplingareapage.DoLayout()
  73. self.summarypage.DoLayout()
  74. self.units.DoLayout()
  75. self.moving.DoLayout()
  76. self.wizard.FitToPage(self.startpage)
  77. #run_wizard
  78. if self.wizard.RunWizard(self.startpage):
  79. dlg = wx.MessageDialog(parent=self.parent,
  80. message=_("Do you want to create r.li " \
  81. "configuration file <%s>?") % self.startpage.conf_name,
  82. caption=_("Create new r.li configuration file?"),
  83. style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
  84. if dlg.ShowModal() == wx.ID_NO:
  85. self._cleanup()
  86. dlg.Destroy()
  87. else:
  88. self._write_confile()
  89. self._cleanup()
  90. dlg.Destroy()
  91. else:
  92. self.wizard.Destroy()
  93. gcmd.GMessage(parent=self.parent,
  94. message=_("r.li.setup wizard canceled. "
  95. "Configuration file not created."))
  96. self._cleanup()
  97. def _write_confile(self):
  98. """Write the configuration file"""
  99. f = open(os.path.join(self.rlipath, self.startpage.conf_name), 'w')
  100. self.rasterinfo = grast.raster_info(self.startpage.rast)
  101. self._write_region(f)
  102. self._write_area(f)
  103. f.close()
  104. def _temp_region(self):
  105. # save current settings:
  106. grass.use_temp_region()
  107. # Temporarily aligning region resolution to $RASTER resolution
  108. # keep boundary settings
  109. grass.run_command('g.region', rast=self.startpage.rast)
  110. self.gregion = grass.region()
  111. self.SF_NSRES = self.gregion['nsres']
  112. self.SF_EWRES = self.gregion['ewres']
  113. def _write_region(self, fil):
  114. """Write the region"""
  115. if self.startpage.region == 'whole':
  116. fil.write("SAMPLINGFRAME 0|0|1|1\n")
  117. self._temp_region()
  118. self.SF_X = 0.0
  119. self.SF_Y = 0.0
  120. self.SF_RL = abs(int(float(self.gregion['s'] - self.gregion['n'])
  121. / float(self.gregion['nsres'])))
  122. self.SF_CL = abs(int(float(self.gregion['e'] - self.gregion['w'])
  123. / float(self.gregion['ewres'])))
  124. self.SF_N = self.gregion['n']
  125. self.SF_S = self.gregion['s']
  126. self.SF_E = self.gregion['e']
  127. self.SF_W = self.gregion['w']
  128. self.per_x = float(self.SF_X) / float(self.rasterinfo['cols'])
  129. self.per_y = float(self.SF_Y) / float(self.rasterinfo['rows'])
  130. self.per_rl = float(self.SF_RL) / float(self.rasterinfo['rows'])
  131. self.per_cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
  132. elif self.startpage.region == 'key':
  133. self._temp_region()
  134. self.SF_X = float(self.keyboardpage.col_up)
  135. self.SF_Y = float(self.keyboardpage.row_up)
  136. self.SF_RL = float(self.keyboardpage.row_len)
  137. self.SF_CL = float(self.keyboardpage.col_len)
  138. self.SF_N = self.gregion['n'] - (self.SF_NSRES * self.SF_Y)
  139. self.SF_S = self.gregion['n'] - (self.SF_NSRES * self.SF_Y + self.SF_RL)
  140. self.SF_W = self.gregion['w'] + (self.SF_EWRES * self.SF_X)
  141. self.SF_E = self.gregion['w'] + (self.SF_EWRES * self.SF_X + self.SF_CL)
  142. self.per_x = float(self.SF_X) / float(self.rasterinfo['cols'])
  143. self.per_y = float(self.SF_Y) / float(self.rasterinfo['rows'])
  144. self.per_rl = float(self.SF_RL) / float(self.rasterinfo['rows'])
  145. self.per_cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
  146. #import pdb; pdb.set_trace()
  147. fil.write("SAMPLINGFRAME %r|%r|%r|%r\n" % (self.per_x, self.per_y,
  148. self.per_rl, self.per_cl))
  149. elif self.startpage.region == 'draw':
  150. self._temp_region()
  151. frame = self.drawsampleframepage.GetSampleFrame()
  152. # should we call this? with align param?
  153. gcmd.RunCommand('g.region', align=self.startpage.rast,
  154. n=frame['n'], s=frame['s'],
  155. w=frame['w'], e=frame['e'])
  156. newreg = grass.region()
  157. self.SF_N = newreg['n'] # set env(SF_N) $n
  158. self.SF_S = newreg['s'] # set env(SF_S) $s
  159. self.SF_E = newreg['e'] # set env(SF_E) $e
  160. self.SF_W = newreg['w'] # set env(SF_W) $w
  161. self.SF_Y = abs(round(self.gregion['n'] - newreg['n']) / newreg['nsres'])
  162. # set env(SF_Y) [expr abs(round(($s_n - $n) / $nres)) ]
  163. self.SF_X = abs(round(self.gregion['w'] - newreg['w']) / newreg['ewres'])
  164. # set env(SF_X) [expr abs(round(($s_w - $w) / $sres)) ]
  165. self.SF_RL = abs(round(newreg['n'] - newreg['s']) / newreg['nsres'])
  166. # set env(SF_RL) [expr abs(round(($n - $s) / $nres)) ]
  167. self.SF_CL = abs(round(newreg['e'] - newreg['w']) / newreg['ewres'])
  168. # set env(SF_CL) [expr abs(round(($e - $w) / $sres)) ]
  169. self.per_x = float(self.SF_X) / float(self.rasterinfo['cols'])
  170. # double($env(SF_X)) / double($cols)
  171. self.per_y = float(self.SF_Y) / float(self.rasterinfo['rows'])
  172. # double($env(SF_Y)) / double($rows)
  173. self.per_rl = float(self.SF_RL) / float(self.rasterinfo['rows'])
  174. # double($env(SF_RL)) / double($rows)
  175. self.per_cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
  176. # double($env(SF_CL)) / double($cols)
  177. fil.write("SAMPLINGFRAME %r|%r|%r|%r\n" % (self.per_x, self.per_y,
  178. self.per_rl, self.per_cl))
  179. def _circle(self, radius, mask):
  180. """create a circle mask"""
  181. self.CIR_RL = round((2 * float(radius)) / float(self.rasterinfo['ewres']))
  182. self.CIR_CL = round((2 * float(radius)) / float(self.rasterinfo['nsres']))
  183. if not self.CIR_RL % 2:
  184. self.CIR_RL += 1
  185. if not self.CIR_CL % 2:
  186. self.CIR_CL += 1
  187. eastEdge = float(self.SF_W + (self.CIR_RL * self.SF_EWRES))
  188. southEdge = float(self.SF_N - (self.CIR_CL * self.SF_NSRES))
  189. grass.del_temp_region()
  190. grass.use_temp_region()
  191. grass.run_command('g.region', n=self.SF_N, s=southEdge, e=eastEdge,
  192. w=self.SF_W)
  193. xcenter = grass.region(complete=True)['center_easting']
  194. ycenter = grass.region(complete=True)['center_northing']
  195. grass.run_command('r.circle', flags='b', out=mask, max=radius,
  196. coordinate=[xcenter, ycenter], quiet=True)
  197. grass.del_temp_region()
  198. grass.use_temp_region()
  199. grass.run_command('g.region', rast=self.startpage.rast)
  200. def _write_area(self, fil):
  201. """Write the region"""
  202. if self.samplingareapage.samplingtype == 'whole':
  203. cl = float(self.SF_CL) / float(self.rasterinfo['cols'])
  204. rl = float(self.SF_RL) / float(self.rasterinfo['rows'])
  205. #this two variable are unused, problably to remove
  206. x = float(self.SF_X) / float(self.rasterinfo['cols'])
  207. y = float(self.SF_Y) / float(self.rasterinfo['rows'])
  208. if self.startpage.region == 'whole':
  209. fil.write("SAMPLEAREA %r|%r|%r|%r\n" % (self.per_x, self.per_y,
  210. rl, cl))
  211. elif self.startpage.region == 'key':
  212. fil.write("SAMPLEAREA %r|%r|%r|%r\n" % (self.per_x, self.per_y,
  213. rl, cl))
  214. elif self.samplingareapage.samplingtype == 'moving':
  215. if self.moving.boxtype == 'circle':
  216. self._circle(self.moving.width, self.moving.height)
  217. cl = float(self.CIR_CL) / float(self.rasterinfo['cols'])
  218. rl = float(self.CIR_RL) / float(self.rasterinfo['rows'])
  219. else:
  220. cl = float(self.moving.width) / float(self.rasterinfo['cols'])
  221. rl = float(self.moving.height) / float(self.rasterinfo['rows'])
  222. fil.write("SAMPLEAREA -1|-1|%r|%r" % (rl, cl))
  223. if self.moving.boxtype == 'circle':
  224. fil.write("|%s" % self.moving.height)
  225. fil.write("\nMOVINGWINDOW\n")
  226. elif self.samplingareapage.samplingtype == 'units':
  227. if self.units.boxtype == 'circle':
  228. self._circle(self.units.width, self.units.height)
  229. cl = float(self.CIR_CL) / float(self.rasterinfo['cols'])
  230. rl = float(self.CIR_RL) / float(self.rasterinfo['rows'])
  231. else:
  232. cl = float(self.units.width) / float(self.rasterinfo['cols'])
  233. rl = float(self.units.height) / float(self.rasterinfo['rows'])
  234. fil.write("SAMPLEAREA -1|-1|%r|%r\n" % (rl, cl))
  235. if self.units.distrtype == 'non_overlapping':
  236. fil.write("RANDOMNONOVERLAPPING %s\n" % self.units.distr1)
  237. elif self.units.distrtype == 'systematic_contiguos':
  238. fil.write("SYSTEMATICCONTIGUOUS\n")
  239. elif self.units.distrtype == 'stratified_random':
  240. fil.write("STRATIFIEDRANDOM %s|%s\n" % (self.units.distr1,
  241. self.units.distr2))
  242. elif self.units.distrtype == 'systematic_noncontiguos':
  243. fil.write("SYSTEMATICNONCONTIGUOUS %s\n" % self.units.distr1)
  244. elif self.units.distrtype == 'centered_oversites':
  245. fil.write("")
  246. def _cleanup(self):
  247. """Clean all the variables to save into configuration file"""
  248. self.startpage.conf_name = ''
  249. self.startpage.rast = ''
  250. self.startpage.vect = ''
  251. self.startpage.region = 'whole'
  252. self.keyboardpage.col_len = ''
  253. self.keyboardpage.col_up = ''
  254. self.keyboardpage.row_len = ''
  255. self.keyboardpage.row_up = ''
  256. self.samplingareapage.samplingtype = 'whole'
  257. self.units.width = ''
  258. self.units.height = ''
  259. self.units.boxtype = ''
  260. self.moving.width = ''
  261. self.moving.height = ''
  262. self.moving.boxtype = ''
  263. class FirstPage(TitledPage):
  264. """
  265. Set name of configuration file, choose raster and optionally vector/sites
  266. """
  267. def __init__(self, wizard, parent):
  268. TitledPage.__init__(self, wizard, _("Select maps and define name"))
  269. self.region = 'whole'
  270. self.rast = ''
  271. self.conf_name = ''
  272. self.vect = ''
  273. self.parent = parent
  274. #name of output configuration file
  275. self.newconflabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  276. label=_('Name for new configuration file to create'))
  277. self.newconftxt = wx.TextCtrl(parent=self, id=wx.ID_ANY,
  278. size=(250, -1))
  279. wx.CallAfter(self.newconftxt.SetFocus)
  280. self.sizer.Add(item=self.newconflabel, border=5, pos=(0, 0),
  281. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  282. self.sizer.Add(item=self.newconftxt, border=5, pos=(0, 1),
  283. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  284. #raster
  285. self.mapsellabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  286. label=_('Raster map to use to select areas'))
  287. self.mapselect = gselect.Select(parent=self, id=wx.ID_ANY,
  288. size=(250, -1), type='cell',
  289. multiple=False)
  290. self.sizer.Add(item=self.mapsellabel, border=5, pos=(1, 0),
  291. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  292. self.sizer.Add(item=self.mapselect, border=5, pos=(1, 1),
  293. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  294. #vector
  295. self.vectsellabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  296. label=_('Vector map to use to select areas'))
  297. self.vectselect = gselect.Select(parent=self, id=wx.ID_ANY,
  298. size=(250, -1), type='vector',
  299. multiple=False)
  300. self.vectsellabel.Enable(False)
  301. self.vectselect.Enable(False)
  302. self.sizer.Add(item=self.vectsellabel, border=5, pos=(2, 0),
  303. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  304. self.sizer.Add(item=self.vectselect, border=5, pos=(2, 1),
  305. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  306. #define sampling region
  307. self.sampling_reg = wx.RadioBox(parent=self, id=wx.ID_ANY,
  308. label=" %s " % _("Define sampling " \
  309. " region (region for analysis)"),
  310. choices=[_('Whole map layer'),
  311. _('Keyboard setting'),
  312. _('Draw the sampling frame')],
  313. majorDimension=1,
  314. style=wx.RA_SPECIFY_ROWS)
  315. # self.sampling_reg.EnableItem(2, False) # disable 'draw' for now
  316. # self.sampling_reg.SetItemToolTip(2, _("This option is not supported yet"))
  317. self.sizer.Add(item=self.sampling_reg,
  318. flag=wx.ALIGN_CENTER | wx.ALL | wx.EXPAND, border=5,
  319. pos=(4, 0), span=(1, 2))
  320. #bindings
  321. self.sampling_reg.Bind(wx.EVT_RADIOBOX, self.OnSampling)
  322. self.newconftxt.Bind(wx.EVT_KILL_FOCUS, self.OnName)
  323. self.newconftxt.Bind(wx.EVT_TEXT, self.OnNameChanged)
  324. self.vectselect.Bind(wx.EVT_TEXT, self.OnVector)
  325. self.mapselect.Bind(wx.EVT_TEXT, self.OnRast)
  326. #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  327. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
  328. wx.CallAfter(wx.FindWindowById(wx.ID_FORWARD).Enable, False)
  329. # wx.FindWindowById(wx.ID_FORWARD).Enable(False)
  330. # self.OnName(None)
  331. def OnSampling(self, event):
  332. """!Change map type"""
  333. if event.GetInt() == 0:
  334. self.region = 'whole'
  335. self.SetNext(self.parent.samplingareapage)
  336. elif event.GetInt() == 1:
  337. self.region = 'key'
  338. self.SetNext(self.parent.keyboardpage)
  339. elif event.GetInt() == 2: # currently disabled
  340. self.region = 'draw'
  341. self.SetNext(self.parent.drawsampleframepage)
  342. def OnName(self, event):
  343. """!Sets the name of configuration file"""
  344. if self.conf_name in self.parent.parent.listfiles:
  345. gcmd.GMessage(parent=self,
  346. message=_("The configuration file %s "
  347. "already exists, please change name") % self.conf_name)
  348. self.newconftxt.SetValue('')
  349. self.conf_name = ''
  350. def OnNameChanged(self, event):
  351. """!Name of configuration file has changed"""
  352. self.conf_name = self.newconftxt.GetValue()
  353. next = wx.FindWindowById(wx.ID_FORWARD)
  354. next.Enable(self.CheckInput())
  355. def OnRast(self, event):
  356. """!Sets raster map"""
  357. self.rast = event.GetString()
  358. next = wx.FindWindowById(wx.ID_FORWARD)
  359. next.Enable(self.CheckInput())
  360. def OnVector(self, event):
  361. """!Sets vector map"""
  362. self.vect = event.GetString()
  363. next = wx.FindWindowById(wx.ID_FORWARD)
  364. next.Enable(self.CheckInput())
  365. def CheckInput(self):
  366. """!Check input fields.
  367. @return True if configuration file is given and raster xor vector map,
  368. False otherwise
  369. """
  370. return bool(self.conf_name and (bool(self.rast) != bool(self.vect)))
  371. def OnExitPage(self, event=None):
  372. """!Function during exiting"""
  373. if self.conf_name == '' or self.rast == '':
  374. wx.FindWindowById(wx.ID_FORWARD).Enable(False)
  375. else:
  376. wx.FindWindowById(wx.ID_FORWARD).Enable(True)
  377. if event.GetDirection():
  378. if self.region == 'key':
  379. self.SetNext(self.parent.keyboardpage)
  380. self.parent.samplingareapage.SetPrev(self.parent.keyboardpage)
  381. elif self.region == 'whole':
  382. self.SetNext(self.parent.samplingareapage)
  383. self.parent.samplingareapage.SetPrev(self)
  384. elif self.region == 'draw':
  385. self.SetNext(self.parent.drawsampleframepage)
  386. self.parent.samplingareapage.SetPrev(self.parent.drawsampleframepage)
  387. return
  388. class KeybordPage(TitledPage):
  389. """
  390. Set name of configuration file, choose raster and optionally vector/sites
  391. """
  392. def __init__(self, wizard, parent):
  393. TitledPage.__init__(self, wizard, _("Insert sampling frame parameter"))
  394. self.parent = parent
  395. self.sizer.AddGrowableCol(2)
  396. self.col_len = ''
  397. self.row_len = ''
  398. self.col_up = '0'
  399. self.row_up = '0'
  400. #column up/left
  401. self.ColUpLeftlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  402. label=_("Column of upper left " \
  403. "corner"))
  404. self.ColUpLefttxt = wx.TextCtrl(parent=self, id=wx.ID_ANY,
  405. size=(250, -1))
  406. wx.CallAfter(self.ColUpLeftlabel.SetFocus)
  407. self.sizer.Add(item=self.ColUpLeftlabel, border=5, pos=(1, 1),
  408. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  409. self.sizer.Add(item=self.ColUpLefttxt, border=5, pos=(1, 2),
  410. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  411. #row up/left
  412. self.RowUpLeftlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  413. label=_('Row of upper left corner'))
  414. self.RowUpLefttxt = wx.TextCtrl(parent=self, id=wx.ID_ANY,
  415. size=(250, -1))
  416. wx.CallAfter(self.RowUpLeftlabel.SetFocus)
  417. self.sizer.Add(item=self.RowUpLeftlabel, border=5, pos=(2, 1),
  418. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  419. self.sizer.Add(item=self.RowUpLefttxt, border=5, pos=(2, 2),
  420. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  421. #row lenght
  422. self.RowLenlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  423. label=_('Row lenght of sampling frame'))
  424. self.RowLentxt = wx.TextCtrl(parent=self, id=wx.ID_ANY, size=(250, -1))
  425. wx.CallAfter(self.RowLenlabel.SetFocus)
  426. self.sizer.Add(item=self.RowLenlabel, border=5, pos=(3, 1),
  427. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  428. self.sizer.Add(item=self.RowLentxt, border=5, pos=(3, 2),
  429. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  430. #column lenght
  431. self.ColLenlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  432. label=_('Row lenght of sampling frame'))
  433. self.ColLentxt = wx.TextCtrl(parent=self, id=wx.ID_ANY, size=(250, -1))
  434. wx.CallAfter(self.ColLenlabel.SetFocus)
  435. self.sizer.Add(item=self.ColLenlabel, border=5, pos=(4, 1),
  436. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  437. self.sizer.Add(item=self.ColLentxt, border=5, pos=(4, 2),
  438. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  439. self.ColUpLefttxt.SetValue(self.col_up)
  440. self.RowUpLefttxt.SetValue(self.row_up)
  441. self.ColUpLefttxt.Bind(wx.EVT_KILL_FOCUS, self.OnColLeft)
  442. self.RowUpLefttxt.Bind(wx.EVT_KILL_FOCUS, self.OnRowLeft)
  443. self.ColLentxt.Bind(wx.EVT_KILL_FOCUS, self.OnColLen)
  444. self.RowLentxt.Bind(wx.EVT_KILL_FOCUS, self.OnRowLen)
  445. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  446. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
  447. def OnColLeft(self, event):
  448. """!Sets the name of configuration file"""
  449. self.col_up = self.ColUpLefttxt.GetValue()
  450. checkValue(self.col_up)
  451. def OnRowLeft(self, event):
  452. """!Sets the name of configuration file"""
  453. self.row_up = self.RowUpLefttxt.GetValue()
  454. checkValue(self.row_up)
  455. def OnColLen(self, event):
  456. """!Sets the name of configuration file"""
  457. self.col_len = self.ColLentxt.GetValue()
  458. checkValue(self.col_len)
  459. def OnRowLen(self, event):
  460. """!Sets the name of configuration file"""
  461. self.row_len = self.RowLentxt.GetValue()
  462. checkValue(self.row_len)
  463. def OnEnterPage(self, event):
  464. """!Sets the default values, for the entire map
  465. """
  466. if self.col_len == '' and self.row_len == '':
  467. rastinfo = grast.raster_info(self.parent.startpage.rast)
  468. self.col_len = rastinfo['cols']
  469. self.row_len = rastinfo['rows']
  470. self.ColLentxt.SetValue(self.col_len)
  471. self.RowLentxt.SetValue(self.row_len)
  472. def OnExitPage(self, event=None):
  473. """!Function during exiting"""
  474. if self.row_len == '' or self.col_len == '' or self.row_up == '' or self.col_up == '':
  475. wx.FindWindowById(wx.ID_FORWARD).Enable(False)
  476. else:
  477. wx.FindWindowById(wx.ID_FORWARD).Enable(True)
  478. class DrawSampleFramePage(TitledPage):
  479. def __init__(self, wizard, parent):
  480. TitledPage.__init__(self, wizard, _("Draw sampling frame"))
  481. self.parent = parent
  482. self.mapPanel = RLiSetupMapPanel(self)
  483. self.mapPanel.sampleFrameChanged.connect(self.SampleFrameChanged)
  484. self.sizer.Add(item=self.mapPanel, flag=wx.EXPAND, pos=(0, 0))
  485. self.sizer.AddGrowableCol(0)
  486. self.sizer.AddGrowableRow(0)
  487. self._raster = None
  488. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  489. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnExitPage)
  490. def SampleFrameChanged(self):
  491. region = self.GetSampleFrame()
  492. if region:
  493. wx.FindWindowById(wx.ID_FORWARD).Enable(True)
  494. else:
  495. wx.FindWindowById(wx.ID_FORWARD).Enable(False)
  496. def GetSampleFrame(self):
  497. return self.mapPanel.GetRegion()
  498. def OnEnterPage(self, event):
  499. self.SampleFrameChanged()
  500. rast = self.parent.startpage.rast
  501. if self._raster != rast:
  502. map_ = self.mapPanel.GetMap()
  503. map_.DeleteAllLayers()
  504. cmdlist = ['d.rast', 'map=%s' % rast]
  505. map_.AddLayer(ltype='raster', command=cmdlist, active=True,
  506. name=rast, hidden=False, opacity=1.0,
  507. render=True)
  508. def OnExitPage(self, event=None):
  509. """!Function during exiting"""
  510. if event.GetDirection():
  511. self.SetNext(self.parent.samplingareapage)
  512. self.parent.samplingareapage.SetPrev(self)
  513. class SamplingAreasPage(TitledPage):
  514. """
  515. Set name of configuration file, choose raster and optionally vector/sites
  516. """
  517. def __init__(self, wizard, parent):
  518. TitledPage.__init__(self, wizard, _("Insert sampling areas"))
  519. self.samplingtype = 'whole'
  520. self.parent = parent
  521. # toggles
  522. self.radioBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
  523. label="",
  524. choices=[_("Whole map layer"),
  525. _("Regions"),
  526. _("Sample units"),
  527. _("Moving window"),
  528. _("Select areas from the\n"
  529. "overlayed vector map")],
  530. majorDimension=1,
  531. style=wx.RA_SPECIFY_COLS | wx.NO_BORDER)
  532. self.radioBox.EnableItem(1, False)
  533. self.radioBox.SetItemToolTip(1, _("This option is not supported yet"))
  534. # layout
  535. self.sizer.SetVGap(10)
  536. self.sizer.Add(item=self.radioBox, flag=wx.ALIGN_LEFT, pos=(0, 0))
  537. self.regionBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
  538. label=_("Choose a method"),
  539. choices=[_('Use keyboard to enter sampling area'),
  540. _('Use mouse to draw sampling area')],
  541. majorDimension=1,
  542. style=wx.RA_SPECIFY_ROWS)
  543. self.regionBox.EnableItem(1, False)
  544. self.regionBox.SetItemToolTip(1, _("This option is not supported yet"))
  545. self.sizer.Add(self.regionBox, flag=wx.ALIGN_CENTER, pos=(1, 0))
  546. # bindings
  547. self.radioBox.Bind(wx.EVT_RADIOBOX, self.SetVal)
  548. self.regionBox.Bind(wx.EVT_RADIOBOX, self.OnRegionDraw)
  549. self.regionbox = 'keybord'
  550. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  551. def OnEnterPage(self, event):
  552. """!Insert values into text controls for summary of location
  553. creation options
  554. """
  555. self.SetVal(None)
  556. if self.parent.startpage.vect:
  557. self.radioBox.ShowItem(4, True)
  558. else:
  559. self.radioBox.ShowItem(4, False)
  560. self.sizer.Layout()
  561. wx.FindWindowById(wx.ID_FORWARD).Enable(True)
  562. def SetVal(self, event):
  563. """!Choose method"""
  564. radio = self.radioBox.GetSelection()
  565. if radio == 0:
  566. self.samplingtype = 'whole'
  567. self.DrawNothing()
  568. # elif event.GetInt() == 1: # disabled
  569. # self.samplingtype = 'regions'
  570. # self.Region()
  571. elif radio == 2:
  572. self.samplingtype = 'units'
  573. self.SetNext(self.parent.units)
  574. self.KeyDraw()
  575. elif radio == 3:
  576. self.samplingtype = 'moving'
  577. self.SetNext(self.parent.moving)
  578. self.KeyDraw()
  579. elif radio == 4:
  580. self.samplingtype = 'vector'
  581. self.DrawNothing()
  582. def Region(self):
  583. """show this only if radio2 it is selected"""
  584. try:
  585. self.sizer.Hide(self.regionBox)
  586. self.sizer.Remove(self.regionBox)
  587. self.sizer.Layout()
  588. except:
  589. pass
  590. gcmd.GMessage(parent=self, message=_("Function not supported yet"))
  591. return
  592. def KeyDraw(self):
  593. """Show this only if radio3 and radio4 it is selected"""
  594. self.sizer.Show(self.regionBox)
  595. self.sizer.Layout()
  596. def OnRegionDraw(self, event):
  597. """Function called by KeyDraw to find what method is choosed"""
  598. if event.GetInt() == 0:
  599. self.regionbox = 'keybord'
  600. self.SetNext(self.parent.units)
  601. elif event.GetInt() == 1:
  602. self.regionbox = 'drawmouse'
  603. return
  604. #self.SetNext(self.parent.draw)
  605. def DrawNothing(self):
  606. """"""
  607. self.sizer.Hide(self.regionBox)
  608. self.sizer.Layout()
  609. self.SetNext(self.parent.summarypage)
  610. class SampleUnitsKeyPage(TitledPage):
  611. """!Set values from keyboard for sample units"""
  612. def __init__(self, wizard, parent):
  613. TitledPage.__init__(self, wizard, _("Units"))
  614. self.parent = parent
  615. self.scrollPanel = scrolled.ScrolledPanel(parent=self, id=wx.ID_ANY)
  616. self.scrollPanel.SetupScrolling(scroll_x=False)
  617. self.panelSizer = wx.GridBagSizer(5, 5)
  618. self.width = ''
  619. self.height = ''
  620. self.boxtype = 'rectangle'
  621. self.distrtype = 'non_overlapping'
  622. # type of shape
  623. self.typeBox = wx.RadioBox(parent=self.scrollPanel, id=wx.ID_ANY,
  624. majorDimension=1, style=wx.RA_SPECIFY_COLS,
  625. label=" %s " % _("Select type of shape"),
  626. choices=[_('Rectangle'), _('Circle')])
  627. self.panelSizer.Add(self.typeBox, flag=wx.ALIGN_LEFT, pos=(0, 0),
  628. span=(1, 2))
  629. self.widthLabel = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY)
  630. self.widthTxt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
  631. size=(250, -1))
  632. self.panelSizer.Add(item=self.widthLabel, pos=(1, 0),
  633. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  634. self.panelSizer.Add(item=self.widthTxt, pos=(1, 1),
  635. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  636. self.heightLabel = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY)
  637. self.heightTxt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
  638. size=(250, -1))
  639. self.panelSizer.Add(item=self.heightLabel, pos=(2, 0),
  640. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  641. self.panelSizer.Add(item=self.heightTxt, pos=(2, 1),
  642. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  643. self.widthLabels = [_('Width size (in cells)? '),
  644. _('What radius size (in meters)? ')]
  645. self.heightLabels = [_('Height size (in cells)? '),
  646. _('Name of the circle mask')]
  647. self.distributionBox = wx.RadioBox(parent=self.scrollPanel,
  648. id=wx.ID_ANY,
  649. majorDimension=1,
  650. style=wx.RA_SPECIFY_COLS,
  651. label= " %s " % _("Select method of sampling unit distribution"),
  652. choices=[_('Random non overlapping'),
  653. _('Systematic contiguos'),
  654. _('Stratified random'),
  655. _('Systematic non contiguos'),
  656. _('Centered over sites')]
  657. )
  658. self.distributionBox.EnableItem(5, False) # disable 'draw' for now
  659. self.panelSizer.Add(item=self.distributionBox, pos=(3, 0), span=(1, 2),
  660. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  661. self.distr1Label = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY,
  662. label=_("What number of Sampling " \
  663. "Units to use?"))
  664. self.distr1Txt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
  665. size=(250, -1))
  666. self.panelSizer.Add(item=self.distr1Label, pos=(4, 0),
  667. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  668. self.panelSizer.Add(item=self.distr1Txt, pos=(4, 1),
  669. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  670. self.distr2Label = wx.StaticText(parent=self.scrollPanel, id=wx.ID_ANY,
  671. label="")
  672. self.distr2Txt = wx.TextCtrl(parent=self.scrollPanel, id=wx.ID_ANY,
  673. size=(250, -1))
  674. self.panelSizer.Add(item=self.distr2Label, pos=(5, 0),
  675. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  676. self.panelSizer.Add(item=self.distr2Txt, pos=(5, 1),
  677. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  678. self.panelSizer.Hide(self.distr2Txt)
  679. self.typeBox.Bind(wx.EVT_RADIOBOX, self.OnType)
  680. self.distributionBox.Bind(wx.EVT_RADIOBOX, self.OnDistr)
  681. self.widthTxt.Bind(wx.EVT_TEXT, self.OnWidth)
  682. self.heightTxt.Bind(wx.EVT_TEXT, self.OnHeight)
  683. self.distr1Txt.Bind(wx.EVT_TEXT, self.OnDistr1)
  684. self.distr2Txt.Bind(wx.EVT_TEXT, self.OnDistr2)
  685. #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  686. self.sizer.Add(item=self.scrollPanel, pos=(0, 0), flag=wx.EXPAND)
  687. self.sizer.AddGrowableCol(0)
  688. self.sizer.AddGrowableRow(0)
  689. self.scrollPanel.SetSizer(self.panelSizer)
  690. self.OnType(None)
  691. def OnType(self, event):
  692. chosen = self.typeBox.GetSelection()
  693. self.widthLabel.SetLabel(self.widthLabels[chosen])
  694. self.heightLabel.SetLabel(self.heightLabels[chosen])
  695. self.panelSizer.Layout()
  696. if chosen == 0:
  697. self.boxtype = 'rectangle'
  698. else:
  699. self.boxtype = 'circle'
  700. def OnDistr(self, event):
  701. chosen = self.distributionBox.GetSelection()
  702. if chosen == 0:
  703. self.distrtype = 'non_overlapping'
  704. self.distr1Label.SetLabel(_("What number of Sampling Units to use?"))
  705. self.panelSizer.Show(self.distr1Txt)
  706. self.distr2Label.SetLabel("")
  707. self.panelSizer.Hide(self.distr2Txt)
  708. self.panelSizer.Layout()
  709. elif chosen == 1:
  710. self.distrtype = 'systematic_contiguos'
  711. self.distr1Label.SetLabel("")
  712. self.distr2Label.SetLabel("")
  713. self.panelSizer.Hide(self.distr1Txt)
  714. self.panelSizer.Hide(self.distr2Txt)
  715. self.panelSizer.Layout()
  716. elif chosen == 2:
  717. self.distrtype = 'stratified_random'
  718. self.distr1Label.SetLabel(_("Insert number of row strates"))
  719. self.distr2Label.SetLabel(_("Insert number of column strates"))
  720. self.panelSizer.Show(self.distr1Txt)
  721. self.panelSizer.Show(self.distr2Txt)
  722. self.panelSizer.Layout()
  723. elif chosen == 3:
  724. self.distrtype = 'systematic_noncontiguos'
  725. self.distr1Label.SetLabel(_("Insert distance between units"))
  726. self.panelSizer.Show(self.distr1Txt)
  727. self.distr2Label.SetLabel("")
  728. self.panelSizer.Hide(self.distr2Txt)
  729. self.panelSizer.Layout()
  730. elif chosen == 4:
  731. self.distrtype = 'centered_oversites'
  732. self.distr1Label.SetLabel("")
  733. self.distr2Label.SetLabel("")
  734. self.panelSizer.Hide(self.distr2Txt)
  735. self.panelSizer.Hide(self.distr1Txt)
  736. self.panelSizer.Layout()
  737. def OnWidth(self, event):
  738. self.width = event.GetString()
  739. def OnHeight(self, event):
  740. self.height = event.GetString()
  741. def OnDistr1(self, event):
  742. self.distr1 = event.GetString()
  743. def OnDistr2(self, event):
  744. self.distr2 = event.GetString()
  745. class MovingWindows(TitledPage):
  746. """!Set values from keyboard for sample units"""
  747. def __init__(self, wizard, parent):
  748. TitledPage.__init__(self, wizard, _("Units"))
  749. self.parent = parent
  750. self.sizer.AddGrowableCol(2)
  751. self.width = ''
  752. self.height = ''
  753. self.boxtype = ''
  754. # type of shape
  755. self.typeBox = wx.RadioBox(parent=self, id=wx.ID_ANY,
  756. label=" %s " % _("Select type of shape"),
  757. choices=[_('Rectangle'), _('Circle')],
  758. majorDimension=1,
  759. style=wx.RA_SPECIFY_COLS)
  760. self.sizer.Add(self.typeBox, flag=wx.ALIGN_LEFT, pos=(1, 1))
  761. self.typeBox.Bind(wx.EVT_RADIOBOX, self.OnType)
  762. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  763. self.widthLabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  764. label=_('Width size (in cells) ?'))
  765. self.widthTxt = wx.TextCtrl(parent=self, id=wx.ID_ANY, size=(250, -1))
  766. self.sizer.Add(item=self.widthLabel, border=5, pos=(2, 1),
  767. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  768. self.sizer.Add(item=self.widthTxt, border=5, pos=(2, 2),
  769. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  770. self.heightLabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  771. label=_('Height size (in cells) ?'))
  772. self.heightTxt = wx.TextCtrl(parent=self, id=wx.ID_ANY, size=(250, -1))
  773. self.sizer.Add(item=self.heightLabel, border=5, pos=(3, 1),
  774. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  775. self.sizer.Add(item=self.heightTxt, border=5, pos=(3, 2),
  776. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  777. self.widthLabels = [_('Width size (in cells)? '),
  778. _('What radius size (in meters)? ')]
  779. self.heightLabels = [_('Height size (in cells)? '),
  780. _('Name of the circle mask')]
  781. self.widthTxt.Bind(wx.EVT_TEXT, self.OnWidth)
  782. self.heightTxt.Bind(wx.EVT_TEXT, self.OnHeight)
  783. def OnEnterPage(self, event):
  784. self.OnType(None)
  785. def OnType(self, event):
  786. chosen = self.typeBox.GetSelection()
  787. self.widthLabel.SetLabel(self.widthLabels[chosen])
  788. self.heightLabel.SetLabel(self.heightLabels[chosen])
  789. self.sizer.Layout()
  790. if chosen == 0:
  791. self.boxtype = 'rectangle'
  792. else:
  793. self.boxtype = 'circle'
  794. def OnWidth(self, event):
  795. self.width = event.GetString()
  796. def OnHeight(self, event):
  797. self.height = event.GetString()
  798. class SummaryPage(TitledPage):
  799. """!Shows summary result of choosing data"""
  800. def __init__(self, wizard, parent):
  801. TitledPage.__init__(self, wizard, _("Summary"))
  802. global rlisettings
  803. self.parent = parent
  804. self.sizer.AddGrowableCol(2)
  805. #configuration file name
  806. self.conflabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  807. label=_('Configuration file name:'))
  808. self.conftxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  809. label="")
  810. self.sizer.Add(item=self.conflabel, border=5, pos=(0, 0),
  811. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  812. self.sizer.Add(item=self.conftxt, border=5, pos=(0, 1),
  813. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  814. #raster name
  815. self.rastlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  816. label=_('Raster name:'))
  817. self.rasttxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  818. label="")
  819. self.sizer.Add(item=self.rastlabel, border=5, pos=(1, 0),
  820. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  821. self.sizer.Add(item=self.rasttxt, border=5, pos=(1, 1),
  822. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  823. #vector name
  824. self.vectlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  825. label=_('Vector name:'))
  826. self.vecttxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  827. label="")
  828. self.sizer.Add(item=self.vectlabel, border=5, pos=(2, 0),
  829. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  830. self.sizer.Add(item=self.vecttxt, border=5, pos=(2, 1),
  831. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  832. #region type name
  833. self.regionlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  834. label=_('Region type:'))
  835. self.regiontxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  836. label="")
  837. self.sizer.Add(item=self.regionlabel, border=5, pos=(3, 0),
  838. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  839. self.sizer.Add(item=self.regiontxt, border=5, pos=(3, 1),
  840. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  841. #region keyboard
  842. self.regionkeylabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  843. label="")
  844. self.regionkeytxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  845. label="")
  846. self.sizer.Add(item=self.regionkeylabel, border=5, pos=(4, 0),
  847. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  848. self.sizer.Add(item=self.regionkeytxt, border=5, pos=(4, 1),
  849. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  850. self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
  851. #sampling area
  852. self.samplinglabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  853. label=_('Sampling area type:'))
  854. self.samplingtxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  855. label="")
  856. self.sizer.Add(item=self.samplinglabel, border=5, pos=(5, 0),
  857. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  858. self.sizer.Add(item=self.samplingtxt, border=5, pos=(5, 1),
  859. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  860. #shapetype
  861. self.shapelabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  862. label="")
  863. self.shapetxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  864. label="")
  865. self.sizer.Add(item=self.shapelabel, border=5, pos=(6, 0),
  866. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  867. self.sizer.Add(item=self.shapetxt, border=5, pos=(6, 1),
  868. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  869. #shapedim
  870. self.shapewidthlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  871. label="")
  872. self.shapewidthtxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  873. label="")
  874. self.sizer.Add(item=self.shapewidthlabel, border=5, pos=(7, 0),
  875. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  876. self.sizer.Add(item=self.shapewidthtxt, border=5, pos=(7, 1),
  877. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  878. self.shapeheightlabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  879. label="")
  880. self.shapeheighttxt = wx.StaticText(parent=self, id=wx.ID_ANY,
  881. label="")
  882. self.sizer.Add(item=self.shapeheightlabel, border=5, pos=(8, 0),
  883. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  884. self.sizer.Add(item=self.shapeheighttxt, border=5, pos=(8, 1),
  885. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  886. #units type
  887. self.unitslabel = wx.StaticText(parent=self, id=wx.ID_ANY, label="")
  888. self.unitstxt = wx.StaticText(parent=self, id=wx.ID_ANY, label="")
  889. self.sizer.Add(item=self.unitslabel, border=5, pos=(9, 0),
  890. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  891. self.sizer.Add(item=self.unitstxt, border=5, pos=(9, 1),
  892. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  893. self.unitsmorelabel = wx.StaticText(parent=self, id=wx.ID_ANY,
  894. label="")
  895. self.unitsmoretxt = wx.StaticText(parent=self, id=wx.ID_ANY, label="")
  896. self.sizer.Add(item=self.unitsmorelabel, border=5, pos=(10, 0),
  897. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  898. self.sizer.Add(item=self.unitsmoretxt, border=5, pos=(10, 1),
  899. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  900. self.unitsmorelabel2 = wx.StaticText(parent=self, id=wx.ID_ANY,
  901. label="")
  902. self.unitsmoretxt2 = wx.StaticText(parent=self, id=wx.ID_ANY, label="")
  903. self.sizer.Add(item=self.unitsmorelabel2, border=5, pos=(11, 0),
  904. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  905. self.sizer.Add(item=self.unitsmoretxt2, border=5, pos=(11, 1),
  906. flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL)
  907. def OnEnterPage(self, event):
  908. """!Insert values into text controls for summary of location
  909. creation options
  910. """
  911. self.conftxt.SetLabel(self.parent.startpage.conf_name)
  912. self.rasttxt.SetLabel(self.parent.startpage.rast)
  913. self.samplingtxt.SetLabel(self.parent.samplingareapage.samplingtype)
  914. self.regiontxt.SetLabel(self.parent.startpage.region)
  915. self.vecttxt.SetLabel(self.parent.startpage.vect)
  916. if self.parent.startpage.region == 'key':
  917. #region keybord values
  918. self.regionkeylabel.SetLabel(_('Region keybord values:'))
  919. regKeyVals = "Column left up: %s - Row left up: %s\n" \
  920. "Column length: %s - Row length: %s\n" % (
  921. self.parent.keyboardpage.col_up,
  922. self.parent.keyboardpage.row_up,
  923. self.parent.keyboardpage.col_len,
  924. self.parent.keyboardpage.row_len)
  925. self.regionkeytxt.SetLabel(regKeyVals)
  926. else:
  927. self.regionkeylabel.SetLabel("")
  928. self.regionkeytxt.SetLabel("")
  929. if self.parent.samplingareapage.samplingtype == 'units':
  930. self.shapelabel.SetLabel(_('Type of shape:'))
  931. self.shapetxt.SetLabel(self.parent.units.boxtype)
  932. if self.parent.units.boxtype == 'circle':
  933. self.shapewidthlabel.SetLabel(_("Radius size:"))
  934. self.shapeheightlabel.SetLabel(_("Name circle mask:"))
  935. else:
  936. self.shapewidthlabel.SetLabel(_("Width size:"))
  937. self.shapeheightlabel.SetLabel(_("Heigth size:"))
  938. self.shapewidthtxt.SetLabel(self.parent.units.width)
  939. self.shapeheighttxt.SetLabel(self.parent.units.height)
  940. self.unitslabel.SetLabel(_("Method of distribution:"))
  941. self.unitstxt.SetLabel(self.parent.units.distrtype)
  942. if self.parent.units.distrtype == 'non_overlapping':
  943. self.unitsmorelabel.SetLabel(_("Number sampling units:"))
  944. self.unitsmoretxt.SetLabel(self.parent.units.distr1)
  945. elif self.parent.units.distrtype == 'systematic_noncontiguos':
  946. self.unitsmorelabel.SetLabel(_("Distance between units:"))
  947. self.unitsmoretxt.SetLabel(self.parent.units.distr1)
  948. elif self.parent.units.distrtype == 'stratified_random':
  949. self.unitsmorelabel.SetLabel(_("Number row strates:"))
  950. self.unitsmoretxt.SetLabel(self.parent.units.distr1)
  951. self.unitsmorelabel2.SetLabel(_("Number column strates:"))
  952. self.unitsmoretxt2.SetLabel(self.parent.units.distr2)
  953. elif self.parent.samplingareapage.samplingtype == 'moving':
  954. self.shapelabel.SetLabel(_('Type of shape:'))
  955. self.shapetxt.SetLabel(self.parent.moving.boxtype)
  956. if self.parent.moving.boxtype == 'circle':
  957. self.shapewidthlabel.SetLabel(_("Radius size:"))
  958. self.shapeheightlabel.SetLabel(_("Name circle mask:"))
  959. else:
  960. self.shapewidthlabel.SetLabel(_("Width size:"))
  961. self.shapeheightlabel.SetLabel(_("Heigth size:"))
  962. self.shapewidthtxt.SetLabel(self.parent.moving.width)
  963. self.shapeheighttxt.SetLabel(self.parent.moving.height)
  964. else:
  965. self.shapelabel.SetLabel("")
  966. self.shapetxt.SetLabel("")
  967. self.shapewidthlabel.SetLabel("")
  968. self.shapewidthtxt.SetLabel("")
  969. self.shapeheightlabel.SetLabel("")
  970. self.shapeheighttxt.SetLabel("")