wizard.py 48 KB

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