wizard.py 46 KB

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