wizard.py 46 KB

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