wizard.py 46 KB

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