
    ը	f3M                       d Z ddlZddlZddlmZ erddlmZ ddlmZ nddlm	Z ddl
mZ ddlmc mZ ddlmZ ddlmZmZmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlm Z! ddlm"Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/  G d de0      Z1 G d de      Z2 G d de      Z3 G d de      Z4 G d de      Z5 G d de      Z6 G d d e      Z7 G d! d"e      Z8 G d# d$e      Z9 G d% d&e      Z: G d' d(e      Z; G d) d*e      Z<y)+a  
@package rlisetup.py

@brief   GUI per r.li.setup module

Classes:
 - RLiSetupFrame (first frame to show existing conf file and choose some
                 operation)
 - RLIWizard (the main wizard)
 - FirstPage (first page of wizard, choose name of conf file, raster, vector,
              sampling region)
 - Keyboard (page to insert region areas from keyboard)
 - SamplingAreas (define sampling area)
 - SummaryPage (show chosen options)

(C) 2011 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.

@author Luca Delucchi <lucadeluge gmail com>
    N)wxPythonPhoenix)adv)Wizard)wizard)gselect)Button
StaticTextTextCtrl)GridBagSizerTitledPage)
checkValue
retRLiPath)RLiSetupMapPanel)coreraster)vector)CalledModuleError   )SamplingTypeconvertFeatureobtainAreaVectorobtainCategoriessampleAreaVector)GErrorGMessage
RunCommandc                   F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)	RLIWizardz3
    !Start wizard here and finish wizard here
    c                    || _         t        |t        j                  t	        d            | _        t               | _        g | _        t        | j
                  |       | _
        t        | j
                  |       | _        t        | j
                  |       | _        t        | j
                  |       | _        t#        | j
                  |       | _        t'        | j
                  |       | _        t+        | j
                  |       | _        t/        | j
                  |       | _        t3        | j
                  |       | _        t7        | j
                  |       | _        t;        | j
                  |       | _        | j                  j?                  | j                          | j                  jA                  | j                         | j                  j?                  | j                          | j                  j?                  | j                          | j                  jA                  | j                         | j                   jA                  | j                         | j                   j?                  | j$                         | j<                  jA                  | j                          | j<                  j?                  | j$                         | j(                  jA                  | j                          | j(                  j?                  | j$                         | j,                  jA                  | j                          | j,                  j?                  | j0                         | j0                  jA                  | j,                         | j0                  j?                  | j$                         | j8                  jA                  | j                          | j8                  j?                  | j$                         | j4                  jA                  | j                          | j4                  j?                  | j$                         | j$                  jA                  | j                          | j                  jC                          | j                  jC                          | j                  jC                          | j                   jC                          | j$                  jC                          | j(                  jC                          | j,                  jC                          | j0                  jC                          | j<                  jC                          | j8                  jC                          | j4                  jC                          | j
                  jE                  | j                         | j
                  jG                  | j                        rt        jH                  | j                   t	        d      | j                  jJ                  z  t	        d      t        jL                  t        jN                  z  t        jP                  z        }|jS                         t        jT                  k(  r| jW                          n | jY                          | jW                          |j[                          y | jW                          | j
                  j[                          t]        | j                   t	        d             y )Nz.Create new configuration file for r.li modules)parentidtitlez3Do you want to create r.li configuration file <%s>?z#Create new r.li configuration file?)r    messagecaptionstylez;r.li.setup wizard canceled. Configuration file not created.r    r#   )/r    r   wxID_ANY_r   r   rlipath
msAreaList	FirstPage	startpageDrawSampleFramePagedrawsampleframepageKeyboardPagekeyboardpageSamplingAreasPagesamplingareapageSummaryPagesummarypageSampleUnitsKeyPageunitsUnitsMousePage	drawunitsDrawSampleUnitsPagedrawsampleunitspageVectorAreasPagevectorareasMovingKeyPagemovingDrawRegionsPageregionsSetNextSetPrevDoLayout	FitToPage	RunWizardMessageDialog	conf_nameYES_NOYES_DEFAULTICON_QUESTION	ShowModalID_NO_cleanup_write_confileDestroyr   )selfr    dlgs      0/usr/lib/grass83/gui/wxpython/rlisetup/wizard.py__init__zRLIWizard.__init__=   s   yyGH

 "|"4;;5#6t{{D#I (d; 1$++t D&t{{D9'T:
'T:#6t{{D#I *4;;=#DKK6&t{{D9 	t445!!$..1!!$"7"78  (()>)>?  ((8%%dnn5%%d&6&67T223T--.

4001

4++,t445t778  ((8  (()9)9:D112D,,-  !6!67  !1!12  !6!67 	!  ))+""$&&(!!#

!  ))+!!#dnn-;;  0""{{RS..**+?@ii"..023C3CCC }}"((*##%KKMMMOKK!{{T    c                 T   t        t        j                  j                  | j                  | j
                  j                        d      }t        j                  | j
                  j                        | _
        | j                  |       | j                  |       |j                          y)zWrite the configuration filewN)openospathjoinr*   r-   rH   grastraster_inforast
rasterinfo_write_region_write_areaclose)rQ   fs     rS   rO   zRLIWizard._write_confile   sl    dllDNN,D,DEsK++DNN,?,?@1		rU   c                    t        j                          t        j                  d| j                  j                         t        j
                         | _        | j                  d   | _        | j                  d   | _        y )Ng.regionr   nsresewres)	grassuse_temp_regionrun_commandr-   r^   regiongregionSF_NSRESSF_EWRESrQ   s    rS   _temp_regionzRLIWizard._temp_region   sW     	*T^^-@-@A||~W-W-rU   c                 V   | j                   j                  dk(  r|j                  d       | j                          d| _        d| _        t        t        t        | j                  d   | j                  d   z
        t        | j                  d         z              | _
        t        t        t        | j                  d   | j                  d   z
        t        | j                  d	         z              | _        | j                  d   | _        | j                  d   | _        | j                  d   | _        | j                  d   | _        t        | j                        t        | j                   d
         z  | _        t        | j
                        t        | j                   d         z  | _        t        | j                        t        | j                   d         z  | _        t        | j                        t        | j                   d
         z  | _        y| j                   j                  dk(  r| j                          t        | j*                  j,                        | _        t        | j*                  j.                        | _        t        | j*                  j0                        | _
        t        | j*                  j2                        | _        | j                  d   | j4                  | j
                  z  z
  | _        | j                  d   | j4                  | j
                  z  | j                  z   z
  | _        | j                  d   | j6                  | j                  z  z   | _        | j                  d   | j6                  | j                  z  | j                  z   z   | _        t        | j                        t        | j                   d
         z  | _        t        | j
                        t        | j                   d         z  | _        t        | j                        t        | j                   d         z  | _        t        | j                        t        | j                   d
         z  | _        |j                  d| j"                  d| j$                  d| j&                  d| j(                  d	       y| j                   j                  dk(  rZ| j                          | j8                  j:                  }t=        d| j                   j>                  |d   |d   |d   |d          tA        j                         }|d   | _        |d   | _        |d   | _        |d   | _        t        tC        | j                  d   |d   z
        |d   z        | _        t        tC        | j                  d   |d   z
        |d	   z        | _        t        tC        |d   |d   z
        |d   z        | _
        t        tC        |d   |d   z
        |d	   z        | _        t        | j                        t        | j                   d
         z  | _        t        | j
                        t        | j                   d         z  | _        t        | j                        t        | j                   d         z  | _        t        | j                        t        | j                   d
         z  | _        |j                  d| j"                  d| j$                  d| j&                  d| j(                  d	       yy)zWrite the regionwholezSAMPLINGFRAME 0|0|1|1
g        snrf   erW   rg   colsrowskeyzSAMPLINGFRAME |
drawre   )alignrt   rs   rW   ru   N)"r-   rk   writerp   SF_XSF_Yabsintfloatrl   SF_RLSF_CLSF_NSF_SSF_ESF_Wr_   per_xper_yper_rlper_clr1   col_uprow_uprow_lencol_lenrm   rn   r/   tregionr   r^   rh   round)rQ   filr   newregs       rS   r`   zRLIWizard._write_region   sm   >>  G+II/0DIDI$,,s+dll3.??@DLL123DJ $,,s+dll3.??@DLL123DJ S)DIS)DIS)DIS)DItyy)E$//&2I,JJDJtyy)E$//&2I,JJDJ

+eDOOF4K.LLDK

+eDOOF4K.LLDK^^""e+d//667DId//667DIt00889DJt00889DJS)T]]TYY-FGDIS)T]]TYY-F-STDIS)T]]TYY-FGDIS)T]]TYY-F-STDItyy)E$//&2I,JJDJtyy)E$//&2I,JJDJ

+eDOOF4K.LLDK

+eDOOF4K.LLDKII::tzz4;;E ^^""f,..66Gnn))#,#,#,#, \\^FsDIsDIsDIsDIE$,,s"3fSk"ABVG_TUDIE$,,s"3fSk"ABVG_TUDIU6#;#<=wOPDJU6#;#<=wOPDJtyy)E$//&2I,JJDJtyy)E$//&2I,JJDJ

+eDOOF4K.LLDK

+eDOOF4K.LLDKII::tzz4;;EE -rU   c                 h   t        dt        |      z  t        | j                  d         z        | _        t        dt        |      z  t        | j                  d         z        | _        | j                  dz  s| xj                  dz  c_        | j                  dz  s| xj                  dz  c_        y )N   rg   rf   r   )r   r   r_   CIR_RLCIR_CL)rQ   radiuss     rS   _value_for_circlezRLIWizard._value_for_circle   s    Qv.%8P2QQRQv.%8P2QQR{{QKK1K{{QKK1KrU   c                    | j                  |       t        | j                  | j                  | j                  z  z         }t        | j
                  | j                  | j                  z  z
        }t        j                          t        j                          t        j                  d| j
                  ||| j                         t        j                  d      d   }t        j                  d      d   }t        j                  dd||||gd	       t        j                          t        j                          t        j                  d| j                  j                  
       y)zCreate a circle maskre   )rt   rs   ru   rW   T)completecenter_eastingcenter_northingzr.circleb)flagsoutmax
coordinatequietr   N)r   r   r   r   rn   r   r   rm   rh   del_temp_regionri   rj   rk   r-   r^   )rQ   r   maskeastEdge	southEdgexcenterycenters          rS   _circlezRLIWizard._circle  s   v&dkkDMM&ABC$))t{{T]]'BCD	*		Y(diiX,,-.>?,,-.?@)	
 	*T^^-@-@ArU   c                 (   | j                   j                  }| j                   j                  }| j                  j                  }|t
        j                  k(  r\|dk(  r)|dk(  rt
        j                  }|S t
        j                  }|S |dk(  r'|dk(  rt
        j                  }|S t
        j                  }S |t
        j                  k(  r\|dk(  r)|dk(  rt
        j                  }|S t
        j                  }|S |dk(  r'|dk(  rt
        j                  }|S t
        j                  }S |t
        j                   k(  rt
        j                   }|S |t
        j"                  k(  rt
        j"                  }|S |t
        j$                  k(  rt
        j$                  }|S |}|S )zObtain the sampling typemousecirclekeyboard)r3   	regionboxsamplingtyper7   boxtyper   UNITSMUNITSCMUNITSRKUNITSCKUNITSRMVWINMMVWINCMMVWINRKMVWINCKMVWINRWHOLEREGIONSVECT)rQ   
devicetyper   	shapetypesamtypes        rS   getSamplingTypezRLIWizard.getSamplingType  s   **44
,,99JJ&&	<---W$(*22G8 5 +22G4 3 z)(*22G. + +22G* ' \///W$(*22G   +22G  z)(*22G  +22G  \///"((G  \111"**G
 	 \..."''G  #GrU   c                    | j                         }|t        j                  k(  rt        | j                        t        | j
                  d         z  }t        | j                        t        | j
                  d         z  }t        | j                        t        | j
                  d         z  }t        | j                        t        | j
                  d         z  }|j                  d| j                  d| j                  d|d|d	       y#|t        j                  k(  r| j                  | j                  j                  | j                  j                          t        | j"                        t        | j
                  d         z  }t        | j$                        t        | j
                  d         z  }|j                  d|d|       |j                  d| j                  j                   z         |j                  d       y#|t        j&                  k(  rt        | j                  j                        t        | j
                  d         z  }t        | j                  j                         t        | j
                  d         z  }|j                  d	|d|       |j                  d       y#|t        j(                  k(  rt        | j*                  d
   d         t        | j
                  d         z  }t        | j*                  d
   d         t        | j
                  d         z  }|j                  d	|d|       |j                  d       y#|t        j,                  k(  r| j/                  | j*                  d
   j0                         t        | j"                        t        | j
                  d         z  }t        | j$                        t        | j
                  d         z  }|j                  d	|d|       |j                  d| j*                  d
   j2                  z         |j                  d       y#|t        j4                  k(  s|t        j6                  k(  rg|t        j4                  k(  r| j                  | j8                  j                  | j8                  j                          t        | j"                        t        | j
                  d         z  }t        | j$                        t        | j
                  d         z  }npt        | j8                  j                        t        | j
                  d         z  }t        | j8                  j                         t        | j
                  d         z  }|j                  d	|d|d       | j8                  j:                  dk(  r)|j                  d| j8                  j<                  z         y#| j8                  j:                  dk(  r|j                  d       y#| j8                  j:                  dk(  rA|j                  d| j8                  j<                  d| j8                  j>                  d       y#| j8                  j:                  dk(  r)|j                  d| j8                  j<                  z         y#| j8                  j:                  dk(  r|j                  d       y#y#| j@                  jB                  t        jD                  t        jF                  fv rtI        jJ                          tI        jL                  d| jN                  jP                         tI        jR                         }|d   }|d   }	t        | j
                  d         }
t        | j
                  d         }| j*                  D ]  }| j@                  jB                  t        jF                  k(  r|jR                  }tU        tW        t        |      |d   z
  |d   z              }tU        tW        t        |	      |d   z
  |d   z              }tU        tW        |d   |d   z
  |d   z              }tU        tW        |d   |d   z
  |d   z              }t        |      t        |      z  }t        |      t        |
      z  }t        |      t        |
      z  }t        |      t        |      z  }tY        |      dz   tY        |      z   dz   tY        |      z   dz   tY        |      z   }| j@                  jB                  t        jD                  k(  r|j                  d|z         | j@                  jB                  t        jF                  k(  s|j                  d|z         |j                  d| j*                  d
   j2                  z         
 y#| j@                  jB                  t        jZ                  k(  rt        | j
                  d         }
t        | j
                  d         }| j*                  D ]  }|jR                  }| j                  tU        tW        | j\                  |d   z
  | j^                  z              z   }| j                  tU        tW        | j`                  |d   z
  | jb                  z              z   }tU        tW        |d   |d   z
        | j^                  z        }tU        tW        |d   |d   z
        | jb                  z        }t        |      t        |      z  }t        |      t        |
      z  }t        |      t        |
      z  }t        |      t        |      z  }tY        |      dz   tY        |      z   dz   tY        |      z   dz   tY        |      z   dz   |j2                  z   }|j                  d|z          y#| j@                  jB                  t        jd                  k(  r| j*                  D ]  }|j                  |        |j                  d jg                  | jN                  jP                  !             |j                  d"jg                  | jN                  jh                  !             y#y#)$z!Write the area according the typerv   rw   zSAMPLEAREA ry   rz   zMASKEDSAMPLEAREA -1|-1|z|%sz
MOVINGWINDOW
zSAMPLEAREA -1|-1|r   non_overlappingzRANDOMNONOVERLAPPING %s
systematic_contiguoszSYSTEMATICCONTIGUOUS
stratified_randomzSTRATIFIEDRANDOM systematic_noncontiguoszSYSTEMATICNONCONTIGUOUS %s
centered_oversites re   r   rt   rW   rf   rg   rs   ru   zSQUAREAREA %s
zMASKEDSAMPLEAREA %sz|%s
zRASTERMAP {name}
)namezVECTORMAP {name}
N)5r   r   r   r   r   r_   r   r~   r   r}   r   r   r   r   r?   widthheightr   r   r   r   r+   r   r   r   r   r   r   r7   	distrtypedistr1distr2r3   r   r   r   rh   ri   rj   r-   r^   rk   r   r   strr   r   rm   r   rn   r   formatvect)rQ   r   r   clrlxy
rastregions_ns_wrw   rv   r   abs_yabs_xabs_rlabs_clsareamarearl   maskAreas                        rS   ra   zRLIWizard._write_areaD  s	   &&( l(((tzz"U4??6+B%CCBtzz"U4??6+B%CCBdii 5)@#AAAdii 5)@#AAAIIDJJ

BPRST,,,LL**DKK,>,>?t{{#eDOOF,C&DDBt{{#eDOOF,C&DDBIIB?@IIedkk0001II(),,,t{{(()E$//&2I,JJBt{{))*U4??63J-KKBII"b9:II(),,,tq)&12U4??6;R5SSBtq)&12U4??6;R5SSBII"b9:II(),,,""4??1#5#<#<=t{{#eDOOF,C&DDBt{{#eDOOF,C&DDBII"b9:IIedooa07778II() ,,,<;O;O0O,...TZZ--tzz/@/@A4;;'%0G*HH4;;'%0G*HH4::++,uT__V5L/MM4::,,-doof6M0NNIIB;<zz##'88		5

8I8IIJ%%)??		23%%)<<		26**2C2CTZZEVEVW %%)BB		84::;L;LLM%%)==		" > ""//    4
 

 !!#j1D1DEJS/CS/C01D01D?? C((559M9MM%nnGE5:#<@P"PQRE5:#<@P"PQRUGCL73<$?77CS#STUUGCL73<$?77CS#STU%L5;.%L5;.6]U4[06]U4[0As1v-3c"g=Cc"gM((559M9MMII/%78**77<;O;OOII3e;<IIg(:(A(AAB#C& ""//<3G3GG01D01D 8,,		C499ws|3t}}DE%  		C499ws|3t}}DE%  U73<'#,#>?$--OPU73<'#,#>?$--OP%L5;.%L5;.6]U4[06]U4[0 F!f  "g	
  "g  ll#  		+h67788 ""//<3D3DD !		% !II*11t~~7J7J1KLII*11t~~7J7J1KL	 ErU   c                    d| j                   _        d| j                   _        d| j                   _        d| j                   _        d| j
                  _        d| j
                  _        d| j
                  _        d| j
                  _	        d| j                  _        d| j                  _        d| j                  _        d| j                  _        d| j                   _        d| j$                  _        d| j$                  _        d| j$                  _        | j&                  | j                   | j(                  | j*                  fD ]3  }|j,                  s|j,                  j.                  j1                          5 y)z7Clean all the variables to save into configuration filer   rr   r   N)r-   rH   r^   r   rk   r1   r   r   r   r   r3   r   r7   r   r   r   rA   
numregionsr?   r/   r;   r=   mapPanel_mgrUnInit)rQ   pages     rS   rN   zRLIWizard._cleanup  s   #%    '$&!#% $&!#% -4*





"# $$LL$$	
 	,D }}""))+	,rU   N)__name__
__module____qualname____doc__rT   rO   rp   r`   r   r   r   ra   rN    rU   rS   r   r   8   s=    Zx.RhB,$LHMT,rU   r   c                   T    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZddZy)r,   zT
    !Set name of configuration file, choose raster and optionally vector/sites
    c           
      Z   t        j                  | |t        d             d| _        d| _        d| _        d| _        d| _        || _        t        | t        j                  t        d            | _        t        | t        j                  d      | _        t        j                  | j                  j                          | j"                  j%                  | j                  d	d
t        j&                  t        j(                  z  t        j*                  z         | j"                  j%                  | j                  d	dt        j&                  t        j(                  z  t        j*                  z         t        | t        j                  t        d            | _        t/        j0                  | t        j                  ddd      | _        | j"                  j%                  | j,                  d	dt        j&                  t        j(                  z  t        j*                  z         | j"                  j%                  | j2                  d	dt        j&                  t        j(                  z  t        j*                  z         t        | t        j                  t        d            | _        t/        j0                  | t        j                  ddd      | _        | j"                  j%                  | j4                  d	dt        j&                  t        j(                  z  t        j*                  z         | j"                  j%                  | j6                  d	dt        j&                  t        j(                  z  t        j*                  z         t        | t        j                  t        d            | _        t        j:                  | t        j                  d      | _        | j"                  j%                  | j8                  d	dt        j&                  t        j(                  z  t        j*                  z         | j"                  j%                  | j<                  d	dt        j&                  t        j(                  z  t        j*                  z         t        j>                  | t        j                  dt        d      z  t        d      t        d      t        d      gdt        j@                         | _!        | j"                  j%                  | jB                  t        jD                  t        j*                  z  t        jF                  z  d	d!d"#       t        | d$      | _$        | jH                  jK                  t        jL                         | j"                  j%                  | jH                  t        jD                  t        j*                  z  t        jF                  z  d	d%d"#       | jB                  jO                  t        jP                  | jR                         | j                  jO                  t        jT                  | jV                         | j                  jO                  t        jX                  | jZ                         | j6                  jO                  t        jX                  | j\                         | j2                  jO                  t        jX                  | j^                         | j<                  jO                  t        jX                  | j`                         | jO                  tb        jd                  | jf                         | jO                  tb        jh                  | jj                         t        j                  t        jl                  t        jn                        jp                  d       y )&NzSelect maps and define namerr   r   Tz)Name for new configuration file to creater    r!   label   r    r!   size   r   r   borderposflagr   r   z!Raster map to use to select areascellF)r    r!   r   typemultipler   r   r   r   z!Vector map to use to select areasr   r   r   r   r   z'Vector map layer to use to select areas   r   r  r    %s z,Define sampling region (region for analysis)Whole map layerzKeyboard settingzDraw the sampling framer   r    r!   r   choicesmajorDimensionr%   r   r   r   r   )r   r   r   span)r      r   )9
TitledPagerT   r)   rk   r^   rH   r   VectorEnabledr    r	   r'   r(   newconflabelr
   
newconftxt	CallAfterSetFocussizerAdd
ALIGN_LEFTALIGN_CENTER_VERTICALALLmapsellabelr   Select	mapselectvectsellabel
vectselectvectlaylabelComboBox	vectlayerRadioBoxRA_SPECIFY_ROWSsampling_regALIGN_CENTEREXPAND	infoErrorSetForegroundColourREDBindEVT_RADIOBOX
OnSamplingEVT_KILL_FOCUSOnNameEVT_TEXTOnNameChangedOnVectorOnRastOnLayerwizEVT_WIZARD_PAGE_CHANGEDOnEnterPageEVT_WIZARD_PAGE_CHANGING
OnExitPageFindWindowById
ID_FORWARDEnablerQ   r   r    s      rS   rT   zFirstPage.__init__  sQ   D&!,I*JK		! 'yy?@
 #$2999M
T__--.

!9!99BFFB	 	 	
 	

OO!9!99BFFB	 	 	
 &BIIQ/R-S
 !BIIIFU
 	

!9!99BFFB	 	 	
 	

NN!9!99BFFB	 	 	
 'BIIQ/R-S
 "..BIIIHu
 	

!9!99BFFB	 	 	
 	

OO!9!99BFFB	 	 	
 'yy=>

 DRYYYO

!9!99BFFB	 	 	
 	

NN!9!99BFFB	 	 	
 KKyy1NOO#$$%+,
 $$
 	

266)BII5 	 	
 $D3**2662

NN266)BII5 	 	
 	r@R..<R[[$*<*<=R[[$--8BKK5BKK6		#--t/?/?@		#..@
R&&r}}5<<eDrU   c                    |j                         dk(  r-d| _        | j                  | j                  j                         y|j                         dk(  r-d| _        | j                  | j                  j
                         y|j                         dk(  r-d| _        | j                  | j                  j                         yy)zChange region typer   rr   r   rx   r   r{   N)GetIntrk   rB   r    r3   r1   r/   rQ   events     rS   r.  zFirstPage.OnSamplingt  s    <<>Q!DKLL556\\^q DKLL112\\^q  DKLL889 !rU   c                    | j                   | j                  j                  j                  v rEt        | t	        d      | j                   z         | j
                  j                  d       d| _         |j                          y)#Sets the name of configuration filez<The configuration file %s already exists, please change namer&   r   N)rH   r    	listfilesr   r)   r  SetValueSkiprA  s     rS   r0  zFirstPage.OnName  sf    >>T[[//999U ..! OO$$R(DN

rU   c                     | j                   j                         | _        t        j                  t        j
                        }|j                  | j                                y)z&Name of configuration file has changedN)r  GetValuerH   r'   r;  r<  r=  
CheckInputrQ   rB  nexts      rS   r2  zFirstPage.OnNameChanged  s=    113  /DOO%&rU   c                     | j                   j                         | _        t        j                  t        j
                        }|j                  | j                                y)zSets raster mapN)r  rI  r^   r'   r;  r<  r=  rJ  rK  s      rS   r4  zFirstPage.OnRast  s=    NN++-	  /DOO%&rU   c                 8   | j                   j                         | _        | j                  r| j                  | j                        \  | _        }| j                  rq| j
                  j                  |       | j
                  j                  d       | j
                  j                         | _        | j                  j                  d       n| j
                  j                          | j
                  j                  d       d| _        nP| j                  j                  d       | j
                  j                          | j
                  j                  d       t        j                  t        j                        }|j!                  | j#                                y)zSets vector mapr   r   N)r   rI  r   CheckVectorr  r#  SetItemsSetSelectionvectorlayerr)  SetLabelClearrF  r'   r;  r<  r=  rJ  )rQ   rB  layersrL  s       rS   r3  zFirstPage.OnVector  s   OO,,.	99)-)9)9$)))D&D!!''/++A.#'>>#:#:#< ''+$$&''+	NN##B'NN  "NN##B'  /DOO%&rU   c                     	 | j                   j                         | _        t        j                  t        j
                        }|j                  | j                                y #  d | _        Y NxY wN)r#  rI  rR  r'   r;  r<  r=  rJ  rK  s      rS   r5  zFirstPage.OnLayer  sT    	$#~~668D   /DOO%&	$#Ds   A$ $	A/c                 &   t        j                  t         j                        }|j                  | j	                                t        j
                  t        j                  t         j                        j                  | j	                                y)+Sets the default values, for the entire mapN)r'   r;  r<  r=  rJ  r  rK  s      rS   r8  zFirstPage.OnEnterPage  sS      /DOO%&
R&&r}}5<<doo>OPrU   c                    	 t        j                  |      d   }|dk(  r+| j                  j	                  t        d      |z         dg fS t        j                  |      d   }|dk(  r+| j                  j	                  t        d      |z         dg fS |dkD  r4g }t        d|dz         D ]  }|j                  t        |              d	|fS dg fS # t        $ r. | j                  j	                  t        d      |z         dg fcY S w xY w)
zSCheck if the type of vector is area and return the number of
        vector's layerareasz5Vector %s was not found, please select another vectorFr   z4Vector %s has no areas, please select another vectornum_dblinksz>Vector %s has no table connected, please select another vectorr   T)
gvectvector_info_topor   r)  rS  r)   vector_inforangeappendr   )rQ   r   r[  linksrU  is         rS   rO  zFirstPage.CheckVector  s$   	**627;E A:NN##KLvU "9!!&)-8A:NN##UV "9QYF1eai( &c!f%&<"9/ ! 	NN##LMPVV "9		s   C 4DDc                     t        | j                  xr, t        | j                  xr t        | j                                    S )zCheck input fields.

        :return: True if configuration file is given and raster xor vector map,
                 False otherwise
        )boolrH   r^   r  ro   s    rS   rJ  zFirstPage.CheckInput  s1     DNNStDII,R$t?Q?Q:R'STTrU   Nc                    t        j                  t         j                        }|j                  | j	                                |j                         r7| j                  dk(  r_| j                  | j                  j                         | j                  j                  j                  | j                  j                         y| j                  dk(  rK| j                  | j                  j                         | j                  j                  j                  |        y| j                  dk(  r_| j                  | j                  j                         | j                  j                  j                  | j                  j                         yyy)Function during exitingrx   rr   r{   N)r'   r;  r<  r=  rJ  GetDirectionrk   rB   r    r1   r3   rC   r/   rK  s      rS   r:  zFirstPage.OnExitPage  s     /DOO%&{{e#T[[556,,44T[[5M5MN'T[[99:,,44T:&T[[<<=,,44T[[5T5TU '  rU   rW  )r   r   r   r   rT   r.  r0  r2  r4  r3  r5  r8  rO  rJ  r:  r   rU   rS   r,   r,     sC    CEJ
:''','Q<UrU   r,   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d
d	Z
y)r0   zL
    !Choose the region setting the values of border using the keyboard
    c                    t        j                  | |t        d             || _        d| _        d| _        d| _        d| _        t        | t        j                  t        d            | _        t        | t        j                  d      | _        t        j                  | j                  j                         | j                   j#                  | j                  dd	t        j$                  t        j&                  z  t        j(                  z  
       | j                   j#                  | j                  ddt        j$                  t        j&                  z  t        j(                  z  
       | j                   j+                  d       t        | t        j                  t        d            | _        t        | t        j                  d      | _        t        j                  | j,                  j                         | j                   j#                  | j,                  ddt        j$                  t        j&                  z  t        j(                  z  
       | j                   j#                  | j.                  ddt        j$                  t        j&                  z  t        j(                  z  
       t        | t        j                  t        d            | _        t        | t        j                  d      | _        t        j                  | j0                  j                         | j                   j#                  | j0                  ddt        j$                  t        j&                  z  t        j(                  z  
       | j                   j#                  | j2                  ddt        j$                  t        j&                  z  t        j(                  z  
       t        | t        j                  t        d            | _        t        | t        j                  d      | _        t        j                  | j4                  j                         | j                   j#                  | j4                  ddt        j$                  t        j&                  z  t        j(                  z  
       | j                   j#                  | j6                  ddt        j$                  t        j&                  z  t        j(                  z  
       | j                  j9                  | j                         | j.                  j9                  | j                         | j                  j;                  t        j<                  | j>                         | j.                  j;                  t        j<                  | j@                         | j6                  j;                  t        j<                  | jB                         | j2                  j;                  t        j<                  | jD                         | j;                  tF        jH                  | jJ                         | j;                  tF        jL                  | jN                         y )NzInsert sampling frame parameterr   0zColumn of upper left cornerr   r   r   r   r  r   r  r   zRow of upper left cornerr  r   r   zRow length of sampling framer  r  r      r   )ro  r   )(r  rT   r)   r    r   r   r   r   r	   r'   r(   ColUpLeftlabelr
   ColUpLefttxtr  r  r  r  r  r  r  AddGrowableColRowUpLeftlabelRowUpLefttxtRowLenlabel	RowLentxtColLenlabel	ColLentxtrF  r,  r/  	OnColLeft	OnRowLeftOnColLenOnRowLenr6  r7  r8  r9  r:  r>  s      rS   rT   zKeyboardPage.__init__  se   D&!,M*NO )BIIQ/O-P
 %DRYYYO
T((112

!9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
 	

!!!$(BIIQ/I-J
 %DRYYYO
T((112

!9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
 &BIIQ/M-N
 "")))L
T%%../

!9!99BFFB	 	 	
 	

NN!9!99BFFB	 	 	
 &BIIQ/M-N
 "")))L
T%%../

!9!99BFFB	 	 	
 	

NN!9!99BFFB	 	 	
 	""4;;/""4;;/r00$..Ar00$..AB--t}}=B--t}}=		#--t/?/?@		#..@rU   c                 l    | j                   j                         | _        t        | j                         yrD  N)rq  rI  r   r   rA  s     rS   ry  zKeyboardPage.OnColLefta  $    ''0024;;rU   c                 l    | j                   j                         | _        t        | j                         yr~  )rt  rI  r   r   rA  s     rS   rz  zKeyboardPage.OnRowLeftf  r  rU   c                 l    | j                   j                         | _        t        | j                         yr~  )rx  rI  r   r   rA  s     rS   r{  zKeyboardPage.OnColLenk  "    ~~..04<< rU   c                 l    | j                   j                         | _        t        | j                         yr~  )rv  rI  r   r   rA  s     rS   r|  zKeyboardPage.OnRowLenp  r  rU   c                 b   | j                   dk(  rV| j                  dk(  rGt        j                  | j                  j
                  j                        }|d   | _         |d   | _        | j                  j                  | j                          | j                  j                  | j                         y)rY  r   rv   rw   N)
r   r   r\   r]   r    r-   r^   rx  rF  rv  )rQ   rB  rastinfos      rS   r8  zKeyboardPage.OnEnterPageu  s     <<2$,,""4(()>)>)C)CDH#F+DL#F+DL--rU   Nc                 F   | j                   dk(  s-| j                  dk(  s| j                  dk(  s| j                  dk(  r3t	        j
                  t        j                        j                  d       yt	        j
                  t        j                        j                  d       y)rg  r   FTN)r   r   r   r   r'   r;  r<  r=  rA  s     rS   r:  zKeyboardPage.OnExitPage  sn     LLB||r!{{b {{b bmm,33E:bmm,33D9rU   rW  )r   r   r   r   rT   ry  rz  r{  r|  r8  r:  r   rU   rS   r0   r0     s-    eAN 
 
!
!
	.
:rU   r0   c                   *    e Zd ZdZd Zd Zd ZddZy)r.   z2Choose the region setting the values drawing a boxc                    t        j                  | |t        d             || _        d | _        d | _        | j                  t        j                  | j                         | j                  t        j                  | j                         y )NzDraw sampling frame)r  rT   r)   r    r   r   r,  r6  r7  r8  r9  r:  r>  s      rS   rT   zDrawSampleFramePage.__init__  sa    D&!,A*BC		#--t/?/?@		#..@rU   c                     |r:|| _         t        j                  t        j                        j	                  d       yt        j                  t        j                        j	                  d       y)z*Enables the next dialog when region is setTFN)r   r'   r;  r<  r=  )rQ   rk   s     rS   SampleFrameChangedz&DrawSampleFramePage.SampleFrameChanged  sF    !DLbmm,33D9bmm,33E:rU   c           	         | j                   t        | d      | _         | j                   j                  j                  | j                         | j
                  j                  | j                   t        j                  d       | j
                  j                  d       | j
                  j                  d       d| _        ni | j                   _        | j	                  d       | j                  j                  j                  }| j                  |k7  rJ| j                   j!                         }|j#                          dd	|z  g}|j%                  d
|d|ddd       yy)Function during enteringN	drawFramesamplingTyper   r   r   r   rk   d.rastmap=%sr   TF      ?ltypecommandactiver   hiddenopacityrender)r   r   sampleFrameChangedconnectr  r  r  r'   r(  rr  AddGrowableRow_raster_regionr    r-   r^   GetMapDeleteAllLayersAddLayerrQ   rB  r^   map_cmdlists        rS   r8  zDrawSampleFramePage.OnEnterPage  s   == ,TLDMMM,,44T5L5LMJJNN4==ryyfNEJJ%%a(JJ%%a(DL$&DMM!t,{{$$))<<4=='')D  "D1GMM  	  rU   Nc                    |j                         rK| j                  | j                  j                         | j                  j                  j	                  |        yt        j                  t
        j                        j                  d       y)rg  TN)	rh  rB   r    r3   rC   r'   r;  r<  r=  rA  s     rS   r:  zDrawSampleFramePage.OnExitPage  sY    LL556KK((006bmm,33D9rU   rW  r   r   r   r   rT   r  r8  r:  r   rU   rS   r.   r.     s    <A;8:rU   r.   c                   R    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zy)r2   z
    Set name of configuration file, choose raster and optionally vector/sites.
    This is coming after choose the region
    c                    t        j                  | |t        d             d| _        || _        d| _        t        j                  | t        j                  dt        d      t        d      t        d      t        d      t        d	      gd
t        j                  t        j                  z        | _        | j                  j                  d       | j                  j                  | j                  t        j                  d       t        j                  | t        j                  t        d      t        d      t        d      gd
t        j                         | _        | j"                  j%                  d
t        d             | j                  j                  | j"                  t        j&                  d       | j                  j)                  t        j*                  | j,                         | j"                  j)                  t        j*                  | j.                         d| _        t        j2                  d
d      | _        t        j6                  | t        j                        | _        t;        | j8                  t        j                  t        d            | _        t?        | j8                  t        j                  d      | _         | j4                  j                  | j<                  t        j&                  d       | j4                  j                  | j@                  t        j&                  d       | j8                  jC                  | j4                         | j                  j                  | j8                  t        j&                  d       t        j2                  dd      | _"        t        j6                  | t        j                        | _#        t;        | jF                  t        j                  t        d            | _$        t        jJ                  | jF                  t        j                        | _&        t;        | jF                  t        j                  t        d            | _'        tQ        | jF                  t        j                  d d!      | _)        | jR                  jU                  t        d"             tQ        | jF                  t        j                  d#d!      | _+        | jV                  jU                  t        d$             | jR                  j)                  t        jX                  | jZ                         | jV                  j)                  t        jX                  | j\                         | jL                  j)                  t        j^                  | j`                         | jD                  j                  | jH                  t        j&                  d       | jD                  j                  | jL                  t        j&                  d       | jD                  j                  | jN                  t        j&                  d       | jD                  j                  | jR                  t        j&                  d%       | jD                  j                  | jV                  t        j&                  d&       | jF                  jC                  | jD                         | j                  j                  | jF                  t        j&                  d'       t;        | t        j                  t        d(            | _1        | j                  j                  | jb                  t        j&                  d)       d| _2        | j@                  j)                  t        jf                  | jh                         | j)                  tj        jl                  | jn                         y )*NzInsert sampling areasrr   Fr   r  RegionszSample unitszMoving windowz)Select areas from the
overlaid vector mapr   r	  
   r   r  zChoose a methodz#Use keyboard to enter sampling areazUse mouse to draw sampling areaz This option is not supported yetr   r   r   r    r!   zNumber of regions to draw:r   2   r   r   r   r  r  z>Do you want to overwrite existing temporal maps if they exist?z"Do you want to check vector areas?Yesr  P   zSelect if use area by areaNozAll the features will be usedr  r  r  z Analysing all vector features...ro  r   )8r  rT   r)   r   r    overwriteTempr'   r$  r(   RA_SPECIFY_COLS	NO_BORDERradioBoxr  SetVGapr  r  r%  	regionBoxSetItemToolTipr'  r,  r-  SetValOnRegionDrawr   GridBagSizerregionPanelSizerPanelregionNumPanelr	   regionNumLabelr
   regionNumTxtSetSizerareaPanelSizer	areaPaneloverwriteTextCheckBoxoverwriteCheckareaTextr   areaOK
SetToolTipareaNO
EVT_BUTTON	OnVectYesOnVectNoEVT_CHECKBOXOnOverwritecalculatingAreasr   r1  OnNumRegionsr6  r7  r8  r>  s      rS   rT   zSamplingAreasPage.__init__  s8   D&!,C*DE#"yy#$).!/"AB $$r||3
 	

2

t}}2==fEyy%&7834 $$

 	%%a+M)NO

t~~BOOH 	2??DKK8BOOT->->?# "1 5 hhdryyA(&&yy01

 %&&2998
 	!!$"5"5BOOQW!X!!$"3"3"//v!V$$T%:%:;

t**fM ooa3"))<'>>yyS
 !kkBIIN">>yy89

 T^^RYYxHq!=>?T^^RYYhGq!@AB76  $2B2BC 2 2fU 3 3"//vVBOOP"//vN"//vN 3 34

t~~BOOH *BIIQ/Q-R!
 	

t,,2??Or{{D,=,=>		#--t/?/?@rU   c                    | j                   j                         rw| j                  | j                  j                         t        j                  t
        j                        j                  d       | j                   j                         | _	        yt        j                  t
        j                        j                  d       y)zObtain the number of regionsTFN)
r  rI  rB   r    rA   r'   r;  r<  r=  r   rA  s     rS   r  zSamplingAreasPage.OnNumRegions-  sz    %%'LL,,-bmm,33D9"//88:DObmm,33E:rU   c                 ~   | j                  d       | j                  j                  j                  r$| j                  j                  dd       g | _        n| j                  j                  dd       | j                  j                          t        j                  t        j                        j                  d       y)ZInsert values into text controls for summary of location
        creation options
        Nro  TF)r  r    r-   r   r  ShowItem	vect_datar  Layoutr'   r;  r<  r=  rA  s     rS   r8  zSamplingAreasPage.OnEnterPage6  s     	D;;  %%MM""1d+DNMM""1e,


"--(//5rU   c                 t   | j                   j                         }t        j                  t        j                        j                  d       |dk(  r't        j                  | _        | j                          n%|dk(  rHt        j                  | _        t        j                  t        j                        j                  d       n|dk(  rAt        j                  | _        | j                  j                         }| j                  |       n|dk(  rAt        j                  | _        | j                  j                         }| j                  |       nL|dk(  rGt        j                  | _        t        j                  t        j                        j                  d       | j!                  | j                         y)	zChoose methodTr   r   Fr   r  ro  N)r  GetSelectionr'   r;  r<  r=  r   r   r   DrawNothingr   r   r  
RegionDrawr   r   ShowExtraOptions)rQ   rB  radioregtypes       rS   r  zSamplingAreasPage.SetValC  s0   **,
"--(//5A: , 2 2DaZ , 4 4Dbmm,33E:aZ , 2 2Dnn113GOOG$aZ , 2 2Dnn113GOOG$aZ , 1 1Dbmm,33E:d//0rU   c                 N   |t         j                  k(  r| j                  j                  | j                         | j                  j                  | j
                         | j                  j                  | j                         | j                  j                  | j                         nb|t         j                  k(  s|t         j                  k(  r| j                  j                  | j                         | j                  j                  | j
                         | j                  j                  | j                         | j                  j                  | j                         n|t         j                  k(  r| j                  j                  | j                         | j                  j                  | j                         | j                  j                  | j                         | j                  j                  | j
                         | j                  j                          y)z.Show some extra options for some sampling typeN)r   r   r  Hider  r  r  Showr  r   r   r   r  )rQ   r   s     rS   r  z"SamplingAreasPage.ShowExtraOptionsZ  sE   l***JJOODNN+JJOODNN+JJOOD112JJOOD//0***g9K9K.KJJOOD//0JJOODNN+JJOOD112JJOODNN+)))JJOODNN+JJOOD//0JJOOD112JJOODNN+

rU   c                 B    | j                  |j                                y rW  )r  r@  rA  s     rS   r  zSamplingAreasPage.OnRegionDrawm  s    'rU   c                 B    | j                   j                         | _        y rW  )r  rI  r  rA  s     rS   r  zSamplingAreasPage.OnOverwriteq  s    !0099;rU   c                 $   | j                  | j                  j                         t        j                  t        j
                        j                  d       | j                  j                  j                  | j                  j                         y)zfThe user choose to select the vector areas, this function set the
        next page to VectorAreasPageTN)	rB   r    r=   r'   r;  r<  r=  r   ShowPagerA  s     rS   r  zSamplingAreasPage.OnVectYesu  sY     	T[[,,-
"--(//5##DKK$;$;<rU   c                 J   | j                   j                  | j                         | j                   j                  | j                         | j                   j                  | j
                         | j                   j                  | j                         | j                  | j                  j                         t        | j                  j                  j                  | j                  j                  j                        }t        j                  t!        d      dt#        |      | t        j$                  t        j&                  z  t        j(                  z  t        j*                  z        | _        t#        |      | _        t1        j2                          t5        | j                  j                  j                  | j                  j                  j6                  || j                  j                  j                  | j8                  | j,                        | j                  _        t1        j<                          | j                  j:                  r| j                  j?                  t!        d             t        j@                  t        jB                        jE                  d       | j                  jF                  jI                  | j                  j                         n$| j                  j?                  t!        d             | j,                  jK                          d| _        y)zThe user choose to use all the vector areas, this function analyses
        all the vector areas and fill the msAreaList variablezAnalysing vector)r"   r#   maximumr    r%   zAll feature are been analyzed.TzAn error occurredN)&r  r  r  r  r  r  r  rB   r    r5   r   r-   r   rR  r'   ProgressDialogr)   lenPD_CAN_ABORTPD_APP_MODALPD_AUTO_HIDE	PD_SMOOTH_progressDlg_progressDlgMaxrh   ri   r   r^   r  r+   r   rS  r;  r<  r=  r   r  rP   )rQ   rB  	vect_catss      rS   r  zSamplingAreasPage.OnVectNo|  s    	

--.

++,

'

'T[[,,-$KK!!&&(=(=(I(I
	 --&'&	N//BOO3booET
  #9~!1KK!!&&KK!!&&KK!!--"
 	;;!!!!**1-M+NObmm,33D9KK''(?(?@!!**1-@+AB!!# rU   c                    |dk(  rd| _         | j                  t        j                  k(  r&| j	                  | j
                  j                         y| j                  t        j                  k(  r&| j	                  | j
                  j                         yy|dk(  r-d| _         | j	                  | j
                  j                         yy)z'Set the next page to units or drawunitsr   r   r   r   N)
r   r   r   r   rB   r    r7   r   r?   r9   )rQ   r  s     rS   r  zSamplingAreasPage.RegionDraw  s    a<'DN  L$6$66T[[../""l&8&88T[[//0 9\$DNLL../ rU   c                    | j                   j                  | j                         | j                   j                  | j                         | j                   j                  | j                         | j                   j                  | j
                         | j                   j                          | j                  | j                  j                         y)zRemove all the optional choices. Used also when the wizard enter in
        SamplingAreasPage, all the optional choices should be hide hereN)
r  r  r  r  r  r  r  rB   r    r5   ro   s    rS   r  zSamplingAreasPage.DrawNothing  s~     	

++,

'

'

--.

T[[,,-rU   N)r   r   r   r   rT   r  r8  r  r  r  r  r  r  r  r  r   rU   rS   r2   r2     sB    
`AD;61.&=&!P
0	.rU   r2   c                       e Zd Zd Zd Zd Zy)r@   c                     || _         t        j                  | |t        d             d| _        d | _        | j                  t        j                  | j                         y )NzDraw sampling regionsr   )
r    r  rT   r)   regioncountr   r,  r6  r7  r8  r>  s      rS   rT   zDrawRegionsPage.__init__  sJ    D&!,C*DE		#--t/?/?@rU   c                    |r%| j                   j                  j                  |       | j                  dz   | _        t	        | j                   j
                  j                        }| j                  |kD  rlt        j                  t        j                        j                  d       | j                   j                  j                  | j                   j                         y | j                  j                  t!        d      j#                  | j                  |             t        j                  t        j                        j                  d       y )Nr   Tz+Draw sample region {count} of {num_regions})countnum_regionsF)r    r+   ra  r  r   r3   r   r'   r;  r<  r=  r   r  r5   r"   rS  r)   r   )rQ   r   r   s      rS   afterRegionDrawnz DrawRegionsPage.afterRegionDrawn  s    KK""))%0++a/55@@A
j(bmm,33D9KK''(?(?@JJ?@GG**
 H 
 bmm,33E:rU   c           	      ,   | j                   j                  j                  t        j                  k(  r%| j
                  j                  t        d             nU| j                   j                  j                  t        j                  k(  r$| j
                  j                  t        d             | j                  t        | | j                   j                  j                        | _	        | j                  j                  j                  | j                         | j                  j                  | j                  t        j                   d       | j                  j#                  d       | j                  j%                  d       d| _        | j                   j(                  j*                  }| j                  d	       | j&                  |k7  rJ| j                  j-                         }|j/                          d
d|z  g}|j1                  d|d|ddd       yy)r  Draw moving windows regionDraw sampling regionNr  r   r  r   r   )r   r  r  r   TFr  r  )r    r3   r   r   r   r"   rS  r)   r   r   r   r  r  r  r  r'   r(  rr  r  r  r-   r^   r  r  r  r  s        rS   r8  zDrawRegionsPage.OnEnterPage  s   ;;''448J8JJJJ"> ?@[[))66,:L:LLJJ"8 9:== ,![[99FFDM MM**2243H3HIJJNN4==ryyfNEJJ%%a(JJ%%a(DL{{$$))D)<<4=='')D  "D1GMM  	  rU   N)r   r   r   rT   r  r8  r   rU   rS   r@   r@     s    A;$!rU   r@   c                   J    e Zd ZdZd ZddZddZd Zd Zd Z	d	 Z
d
 Zd Zy)r6   zSet values from keyboard for sample units
    It is used if you choose keyboard from Sampling Units or Moving windows
    in sampling areas page
    c                 >   t        j                  | |t        d             || _        t	        j
                  | t        j                        | _        | j                  j                  d       t        j                  dd      | _        d| _        d| _        d| _        d| _        t        j                   | j                  t        j                  d	t        j"                  d
t        d      z  t        d      t        d      dg      | _        | j                  j'                  | j$                  t        j(                  dd       t+        | j                  t        j                        | _        t/        | j                  t        j                  d      | _        | j                  j'                  | j,                  dt        j(                  t        j2                  z  t        j4                  z         | j                  j'                  | j0                  dt        j(                  t        j2                  z  t        j4                  z         t+        | j                  t        j                        | _        t/        | j                  t        j                  d      | _        | j                  j'                  | j6                  dt        j(                  t        j2                  z  t        j4                  z         | j                  j'                  | j8                  dt        j(                  t        j2                  z  t        j4                  z         t        d      t        d      g| _        t        d      t        d      g| _        t        j                   | j                  t        j                  d	t        j"                  d
t        d      z  t        d      t        d       t        d!      t        d"      t        d#      g      | _        | j                  j'                  | j>                  d$dt        j(                  t        j2                  z  t        j4                  z  %       t+        | j                  t        j                  t        d&      '      | _         t/        | j                  t        j                  d      | _!        | j                  j'                  | j@                  d(t        j(                  t        j2                  z  t        j4                  z         | j                  j'                  | jB                  d)t        j(                  t        j2                  z  t        j4                  z         t+        | j                  t        j                  d'      | _"        t/        | j                  t        j                  d      | _#        | j                  j'                  | jD                  d*t        j(                  t        j2                  z  t        j4                  z         | j                  j'                  | jF                  d+t        j(                  t        j2                  z  t        j4                  z         | j                  jI                  | jF                         | j$                  jK                  t        jL                  | jN                         | j>                  jK                  t        jL                  | jP                         | j0                  jK                  t        jR                  | jT                         | j8                  jK                  t        jR                  | jV                         | jB                  jK                  t        jR                  | jX                         | jF                  jK                  t        jR                  | jZ                         | jK                  t\        j^                  | j`                         | jb                  j'                  | j                  dt        jd                         | jb                  jg                  d,       | jb                  ji                  d,       | j                  jk                  | j                         | jO                  d        y )-Nz!Select sample units from keyboardr  F)scroll_xr   r   	rectangler   r   r  Select type of shape	RectangleCircleNoner    r!   r  r%   r   r
  r   r  r   r   r  r   r   r   )r   r   r  r  r  Width size (in cells)?What radius size (in meters)?Height size (in cells)?Name of the circle maskz+Select method of sampling unit distributionzRandom non overlappingzSystematic contiguouszStratified randomzSystematic non contiguouszCentered over sitesr  )r   r  r   %What number of Sampling Units to use?r   r  rn  r  r   r   r   )6r  rT   r)   r    scrolledScrolledPanelr'   r(   scrollPanelSetupScrollingr  
panelSizerr   r   r   r   r$  r  typeBoxr  r  r	   
widthLabelr
   widthTxtr  r  heightLabel	heightTxtwidthLabelsheightLabelsdistributionBoxdistr1Label	distr1Txtdistr2Label	distr2Txtr  r,  r-  OnTypeOnDistrr1  OnWidthOnHeightOnDistr1OnDistr2r6  r7  r8  r  r(  rr  r  r  r>  s      rS   rT   zSampleUnitsKeyPage.__init__  s   D&!,O*PQ#11"))L'''7//!Q/
"*{{##yy$$1344{^Qx[6;
 	DLLr}}&vV$D,<,<K (8(8RYYYWOO!9!99BFFB 	 	

 	MM!9!99BFFB 	 	
 &T-=-="))L!)9)9biiiX!9!99BFFB 	 	

 	NN!9!99BFFB 	 	
 &'-.
 891=V;WX!{{##yy$$1JKK*+)*%&-.'( 
 	  !9!99BFFB	 	 	
 &##yy>?

 ")9)9biiiX!9!99BFFB 	 	

 	NN!9!99BFFB 	 	

 &T-=-="))SUV!)9)9biiiX!9!99BFFB 	 	

 	NN!9!99BFFB 	 	

 	T^^,"//4;;7!!"//4<<@2;;5BKK7BKK7BKK7		#--t/?/?@

t''V"))D

!!!$

!!!$!!$//2DrU   Nc                     | j                   j                  d      f | j                   j                  dd       | j                  j	                          y)r  r   FN)r  rQ  r  r  r  rA  s     rS   r8  zSampleUnitsKeyPage.OnEnterPage  s=     	!!!$%a' rU   c                     |j                         rK| j                  | j                  j                         | j	                  | j                  j
                         yyrg  N)rh  rB   r    r5   rC   r3   rA  s     rS   r:  zSampleUnitsKeyPage.OnExitPage  s?    LL001LL556  rU   c                 4   | j                   j                         }| j                  j                  | j                  |          | j
                  j                  | j                  |          | j                  j                          |dk(  rd| _	        yd| _	        y)z'Set if rectangle or circle will be usedr   r  r   N)
r  r  r  rS  r  r  r  r  r  r   rQ   rB  chosens      rS   r!  zSampleUnitsKeyPage.OnType  su    **,  !1!1&!9:!!$"3"3F";< Q;&DL#DLrU   c                    | j                   j                         }|dk(  rd| _        | j                  j	                  t        d             | j                  j                  | j                         | j                  j	                  d       | j                  j                  | j                         | j                  j                          y |dk(  rd| _        | j                  j	                  d       | j                  j	                  d       | j                  j                  | j                         | j                  j                  | j                         | j                  j                          y |dk(  rd| _        | j                  j	                  t        d	             | j                  j	                  t        d
             | j                  j                  | j                         | j                  j                  | j                         | j                  j                          y |dk(  rd| _        | j                  j	                  t        d             | j                  j                  | j                         | j                  j	                  d       | j                  j                  | j                         | j                  j                          y |dk(  rd| _        | j                  j	                  d       | j                  j	                  d       | j                  j                  | j                         | j                  j                  | j                         | j                  j                          y y )Nr   r   r  r   r   r   r   r   zInsert number of row strateszInsert number of column stratesr  r   zInsert distance between unitsro  r   )r  r  r   r  rS  r)   r  r  r  r  r  r   r  r+  s      rS   r"  zSampleUnitsKeyPage.OnDistr  sm   %%224Q;.DN%%a(O&PQOO  0%%b)OO  0OO""$q[3DN%%b)%%b)OO  0OO  0OO""$q[0DN%%a(F&GH%%a(I&JKOO  0OO  0OO""$q[6DN%%a(G&HIOO  0%%b)OO  0OO""$q[1DN%%b)%%b)OO  0OO  0OO""$ rU   c                 B    | j                   j                         | _        y rW  )r  rI  r   rA  s     rS   r#  zSampleUnitsKeyPage.OnWidth  s    ]]++-
rU   c                 B    | j                   j                         | _        y rW  )r  rI  r   rA  s     rS   r$  zSampleUnitsKeyPage.OnHeight      nn--/rU   c                 B    | j                   j                         | _        y rW  )r  rI  r   rA  s     rS   r%  zSampleUnitsKeyPage.OnDistr1  r0  rU   c                 B    | j                   j                         | _        y rW  )r   rI  r   rA  s     rS   r&  zSampleUnitsKeyPage.OnDistr2  r0  rU   rW  )r   r   r   r   rT   r8  r:  r!  r"  r#  r$  r%  r&  r   rU   rS   r6   r6     s7    
wr!7	$$%L.000rU   r6   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	r>   z)Set values from keyboard for sample unitsc           	      &   t        j                  | |t        d             || _        d| _        d| _        d| _        t        j                  | t        j                  dt        d      z  t        d      t        d      gdt        j                  	      | _        | j                  j                  | j                  t        j                  d
       | j                  j                  t        j                   | j"                         | j                  t$        j&                  | j(                         t+        | t        j                  t        d            | _        t/        | t        j                  d      | _        | j                  j                  | j,                  ddt        j                  t        j2                  z  t        j4                  z         | j                  j                  | j0                  ddt        j                  t        j2                  z  t        j4                  z         t+        | t        j                  t        d            | _        t/        | t        j                  d      | _        | j                  j                  | j6                  ddt        j                  t        j2                  z  t        j4                  z         | j                  j                  | j8                  ddt        j                  t        j2                  z  t        j4                  z         | j                  j;                  d       t        d      t        d      g| _        t        d      t        d      g| _        | j0                  j                  t        j@                  | jB                         | j8                  j                  t        j@                  | jD                         t        jF                  t        jH                        jK                  d       y )NzSet sample unitsr   r  r  r  r  r  r   r	  r  r  r
  r   r   r   r   r  r   rl  r  r  rm  r   r  r  F)&r  rT   r)   r    r   r   r   r'   r$  r(   r  r  r  r  r  r,  r-  r!  r6  r7  r8  r	   r  r
   r  r  r  r  r  rr  r  r  r1  r#  r$  r;  r<  r=  r>  s      rS   rT   zMovingKeyPage.__init__  s   D&!,>*?@
"{{yy1344{^Qx[1$$
 	

t||"--VD"//4;;7		#--t/?/?@$BIIQ/G-H
 !K

OO!9!99BFFB	 	 	
 	

MM!9!99BFFB	 	 	
 &BIIQ/H-I
 "")))L

!9!99BFFB	 	 	
 	

NN!9!99BFFB	 	 	
 	

!!!$&'-.
 891=V;WX2;;5BKK7
"--(//6rU   c                     | j                   j                  j                  t        j                  k(  r$| j
                  j                  t        d             | j                  d        y )NzSet moving windows)	r    r3   r   r   r   r"   rS  r)   r!  rA  s     rS   r8  zMovingKeyPage.OnEnterPage  sF     ;;''448J8JJJJ"6 78DrU   c                    | j                   j                         }| j                  j                  | j                  |          | j
                  j                  | j                  |          | j                  j                          |dk(  r1t        j                  | j                  j                  _        d| _        y |dk(  r1t        j                  | j                  j                  _        d| _        y y )Nr   r  r   r   )r  r  r  rS  r  r  r  r  r  r   r   r    r3   r   r   r   r+  s      rS   r!  zMovingKeyPage.OnType  s    **,  !1!1&!9:!!$"3"3F";<

Q;8D8L8LDKK((5&DLq[8D8L8LDKK((5#DL rU   c                 Z    t        | j                  xr t        | j                              S )zCheck input fields.

        :return: True if configuration file is given and raster xor
                 vector map, False otherwise
        )re  r   r   ro   s    rS   rJ  zMovingKeyPage.CheckInput&  s!     DJJ44#455rU   c                     | j                   j                         | _        t        j                  t        j
                        }|j                  | j                                y rW  )r  rI  r   r'   r;  r<  r=  rJ  rK  s      rS   r#  zMovingKeyPage.OnWidth.  s=    ]]++-
  /DOO%&rU   c                     | j                   j                         | _        t        j                  t        j
                        }|j                  | j                                y rW  )r  rI  r   r'   r;  r<  r=  rJ  rK  s      rS   r$  zMovingKeyPage.OnHeight3  s=    nn--/  /DOO%&rU   N)
r   r   r   r   rT   r8  r!  rJ  r#  r$  r   rU   rS   r>   r>     s%    3A7F
$6'
'rU   r>   c                   0    e Zd ZdZd Zd Zd Zd ZddZy)	r8   zChoose the sampling area setting the values using the mouse drawing the
    areas with rectangle or circle. It is used both from 'Moving windows'
    and 'Sample units'.
    c                    || _         || _        t        j                  | | j                  t	        d             d| _        d | _        t        j                  | t        j                  dt        j                  dt	        d      z  t	        d      t	        d      dg      | _        | j                  j                  d	      f | j                  j                  d	d
       | j                  j                  | j                  t        j                   dd       t        j"                  dd	      | _        t        j&                  | t        j                        | _        t+        | j(                  t        j                  t	        d            | _        t/        | j(                  t        j                  d      | _        | j$                  j                  | j,                  t        j2                  d       | j$                  j                  | j0                  t        j2                  d       | j(                  j5                  | j$                         | j                  j                  | j(                  t        j                   dd       | j                  j7                  t        j8                  | j:                         | j0                  j7                  t        j<                  | j>                         | j7                  t@        jB                  | jD                         | j                  jG                  d       | j;                  d        | j0                  jI                  d       y )NDraw sampling unitsr   r   r  r  r  r  r  r   Fr   r  r	  r  z Number of sampling area to draw:r   r  r   r  r   r   r   )%r    r   r  rT   r)   r   r   r'   r$  r(   r  r  rQ  r  r  r  r  r  r  r  r  r	   r  r
   r  r'  r  r,  r-  r!  r1  r  r6  r7  r8  rr  rF  r>  s      rS   rT   zUnitsMousePage.__init__?  sM   D$++q1F/GH{{yy$$1344{^Qx[27
 	!!!$%a'

t||"--V&Q "1 5 hhdryyA(&&yy67

 %&&2998
 	!!$"5"5BOOQW!X!!$"3"3"//v!V$$T%:%:;

t**FQWX"//4;;7r{{D,=,=>		#--t/?/?@

!!!$D""2&rU   c                 ~   | j                   r3t        j                  t        j                        j	                  d       n2t        j                  t        j                        j	                  d       | j
                  j                  j                  t        j                  t        j                  t        j                  fv r|| j                  j                  t        d             | j                  j!                  | j"                         t        j                  t        j                        j	                  d       n| j
                  j                  j                  t        j$                  t        j&                  t        j(                  fv rI| j                  j                  t        d             | j                  j+                  | j"                         | j,                  j/                         dk(  r2t        j                  t        j                        j	                  d       | j                  j1                          y)r  TFr  r  r   N)r   r'   r;  r<  r=  r    r3   r   r   r   r   r   r"   rS  r)   r  r  r  r   r   r   r  r  r  r  rA  s     rS   r8  zUnitsMousePage.OnEnterPagek  sr   ??bmm,33D9bmm,33E:;;''44    9
 

 JJ"> ?@JJOOD//0bmm,33D9[[))66    ;
 

 JJ"8 9:JJOOD//0<<$$&!+bmm,33E:

rU   c                    | j                   j                         }|dk(  r| j                  j                  j                  t
        j                  t
        j                  t
        j                  fv rct
        j                  | j                  j                  _        t        j                  t        j                        j                  d       d| _        y t
        j                  | j                  j                  _        d| _        y | j                  j                  j                  t
        j                  t
        j                  t
        j                  fv r\t
        j                  | j                  j                  _        t        j                  t        j                        j                  d       n)t
        j                  | j                  j                  _        d| _        y )Nr   Tr  r   )r  r  r    r3   r   r   r   r   r   r'   r;  r<  r=  r   drawtyper   r+  s      rS   r!  zUnitsMousePage.OnType  sE   **,Q;{{++88""$$$$= 
 =I<P<P,,9!!"--077= (DM =I<P<P,,9'DM{{++88""$$$$= 
 =I<P<P,,9!!"--077=<H<P<P,,9$DMrU   c                    | j                   j                         rw| j                  | j                  j                         t        j                  t
        j                        j                  d       | j                   j                         | _	        yt        j                  t
        j                        j                  d       y)zSet the number of regionTFN)
r  rI  rB   r    r;   r'   r;  r<  r=  r   rA  s     rS   r  zUnitsMousePage.OnNumRegions  sz    %%'LL889bmm,33D9"//88:DObmm,33E:rU   Nc                     |j                         r7| j                  | j                         | j                  | j                         yyr)  )rh  rB   r;   rC   r3   rA  s     rS   r:  zUnitsMousePage.OnExitPage  s7    LL112LL../  rU   rW  )	r   r   r   r   rT   r8  r!  r  r:  r   rU   rS   r8   r8   9  s!    
*'X2%2;0rU   r8   c                   *    e Zd ZdZd Zd Zd ZddZy)r:   z%Choose the sampling area drawing themc                     t        j                  | |t        d             || _        d | _        | j                  t        j                  | j                         y )Nr<  )	r  rT   r)   r    r   r,  r6  r7  r8  r>  s      rS   rT   zDrawSampleUnitsPage.__init__  sB    D&!,A*BC		#--t/?/?@rU   c                    |r%| j                   j                  j                  |       | j                  dz   | _        | j                   j                  j
                  }| j                  | j                  kD  rlt        j                  t        j                        j                  d       | j                   j                  j                  | j                   j                         y | j                  j                  t!        d      j#                  || j                  | j                               t        j                  t        j                        j                  d       y )Nr   Tz2Draw sampling {draw_type} {count} of {num_regions})	draw_typer  r  F)r    r+   ra  r  r9   r?  r   r'   r;  r<  r=  r   r  r5   r"   rS  r)   r   )rQ   rk   r?  s      rS   r  z&DrawSampleUnitsPage.SampleFrameChanged  s    KK""))&1++a/;;((11doo-bmm,33D9KK''(?(?@JJFGNN&** $ O  bmm,33E:rU   c           	         | j                   j                  j                  t        j                  t        j
                  t        j                  fv rd| _        n.t        | j                   j                  j                        | _        d| _
        | j                  r%| j                  j                  | j                         | j                   j                  j                  }t        | | j                   j                  j                        | _        |dk(  r0| j                  j                   j#                  | j$                         n/| j                  j&                  j#                  | j$                         | j                  j)                  | j                  t*        j,                  d       | j                  j/                  d       | j                  j1                  d       d| _        | j%                  d       | j                   j4                  j6                  }| j2                  |k7  rJ| j                  j9                         }|j;                          d	d
|z  g}|j=                  d|d|ddd       yy)r  r   r   r  r   r   r  Nr  r  r  r   TFr  r  )r    r3   r   r   r   r   r   r   r   r9   r  r   r  Remover?  r   afterCircleDrawnr  r  r  r  r'   r(  rr  r  r  r-   r^   r  r  r  )rQ   rB  gtyper^   r  r  s         rS   r8  zDrawSampleUnitsPage.OnEnterPage  s    ;;''44    9
 

  DO!$++"7"7"B"BCDO==JJdmm,%%..(55BB
 HMM**2243J3JKMM,,44T5L5LM

t}}299&A

!!!$

!!!$t,{{$$))<<4=='')D  "D1GMM  	  rU   Nc                      yr)  r   rA  s     rS   r:  zDrawSampleUnitsPage.OnExitPage  s    rU   rW  r  r   rU   rS   r:   r:     s    /A;(-^rU   r:   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d
d	Z
y)r<   z2Choose the sampling area using the vector featuresc                 ~   t        j                  | |t        d             || _        d| _        d | _        | j                  t        j                  | j                         | j                  t        j                  | j                         t        j                  dd      | _        t        j                  | t        j                         | _        t%        | j"                  t        j                   t        d            | _        t)        | j"                  t        j                   dd	      | _        t)        | j"                  t        j                   d
d	      | _        | j*                  j                  t        j.                  | j0                         | j,                  j                  t        j.                  | j2                         | j                  j5                  | j&                  t        j6                  d       | j                  j5                  | j*                  t        j6                  d       | j                  j5                  | j,                  t        j6                  d       | j"                  j9                  | j                         | j:                  j5                  | j"                  t        j6                  d       y )NzSelect sampling areasr   r   r  r  zIs this area ok?r   r  r  r  r   r  r   )r   r   r  )r  rT   r)   r    
areascountr   r,  r6  r7  r8  r9  r:  r'   r  r  r  r(   r  r	   r  r   r  r  r  OnYesOnNor  r'  r  r  r>  s      rS   rT   zVectorAreasPage.__init__  s   D&!,C*DE		#--t/?/?@		#..@ ooa3"))<">>biiq9K7L
 T^^RYYxHT^^RYYhG

3		2BOOP"//vN"//vN 3 34

t~~BOOHrU   c                 ,   | j                   dz   | _         | j                   | j                  k(  rit        j                  t        j                        j                  d       | j                  j                  d       | j                  j                  d       y| j                  j                  t        d      j                  | j                   dz   | j                               t        j                  t        j                        j                  d       y)z<Function to update the title and the number of selected arear   TFz.Select sample area {areas_count} of {area_num})areas_countarea_num)rM  areanumr'   r;  r<  r=  r  r  r"   rS  r)   r   ro   s    rS   r  z VectorAreasPage.afterRegionDrawn  s    //A-??dll*bmm,33D9KKu%KKu%JJBCJJ $! 3dll K 
 bmm,33E:rU   c                     | j                   j                  j                  t        | j                               | j                         s| j                          yy)zOFunction to create the string for the conf file if the area
        is selectedN)r    r+   ra  r   outnamer  newCatrA  s     rS   rN  zVectorAreasPage.OnYes-  s@     	%%&6t||&DE$$&KKM 'rU   c                 F    | j                         s| j                          yy)z:Function to pass to the next feature if it is not selectedN)r  rV  rA  s     rS   rO  zVectorAreasPage.OnNo4  s    $$&KKM 'rU   c           
      ^   | j                   | j                     }dj                  | j                  j	                  d      d   | j
                  j	                  d      d         | _        dj                  | j                  |      | _        t        t        j                  d| j                  d	            d
k(  r| j                  j                  j                  skt        | t        d| j                  d| j                  d             | j                  j                   j#                  | j                  j                         yt%        | j                  | j                  || j
                  | j                  j&                  j(                  | j                  j                  j                         dd| j                  z  g}| j*                  j-                  d|d| j                  ddd       | j*                  j/                         D ]z  }|j0                  | j                  k(  r*| j2                  j4                  j7                  |gdd       F|j0                  | j
                  k7  s`| j*                  j9                  |       | | j:                  j=                  dj                  |             y)z*Convert to raster and draw the new featurez{rast}_{vect}_@r   )r   r^   z{pref}{cat})prefcatr   .)patternmapsetr   zThe raster map <zD> already exists. Please remove or rename the maps with the prefix 'z1' or select the option to overwrite existing mapsr&   Nr  r  TFr  r  )rU  r  ignoreNullszIs this area (cat={n}) ok?)rt   )r  rM  r   r   splitr^   outprefrU  r  rh   list_stringsr    r3   r  r   r)   r   r  r   r-   rR  r  r  GetListOfLayersr   r   	mapWindow	ZoomToMapDeleteLayerr  rS  )rQ   r[  
cmdlistcatls       rS   rV  zVectorAreasPage.newCat9  s   nnT__-'..%a(tyys/CA/F / 
 %++3+G ""8T\\#NOSTTKK00>> <@<<W KK''(D(DEIILLIIKK!!--KK((66	
 4<< 78
		 	 	
 **, 	)Avv%''113t 2  499$		%%a(	) 	;BBSBIJrU   c           	      6   | j                   t        | | j                  j                  j                        | _         | j
                  j                  | j                   t        j                  d       | j
                  j                  d       | j
                  j                  d       d| _        | j                  j                  j                  | _        | j                  j                  j                  | _        t        | j                  | j                  j                  j                         | _        t%        | j"                        | _        | j&                  dk(  rPt)        | t+        d      	       | j                  j,                  j/                  | j                  j                         y| j0                  j3                  t+        d
t5        | j&                        z                t7        j8                          | j                  | j                  k7  rv| j                   j;                         | _        | j<                  j?                          dd| j                  z  g}| j<                  jA                  d|d| j                  ddd       | jC                          y)zRFunction during entering: draw the raster map and the first vector
        featureNr  r   r  r   r   )layerz!The polygon seems to have 0 areasr&   zSelect sample area 1 of r  r  r   TFr  r  )"r   r   r    r3   r   r  r  r'   r(  rr  r  r  r-   r^   r   r   rR  r  r  rS  r   r)   r   r  r"   rS  r   rh   ri   r  r  r  r  rV  )rQ   rB  r  s      rS   r8  zVectorAreasPage.OnEnterPagel  s    == ,4;;#?#?#L#LDM JJNN4==ryyfNEJJ%%a(JJ%%a(DLKK))..	KK))..	)IIT[[22>>
 4>>*<<1$*M(NOKK''(D(DE

A83t||;LLMN<<499$,,.DIII%%'DII!56GIIYY   	rU   Nc                 ,    t        j                          yr)  )rh   r   rA  s     rS   r:  zVectorAreasPage.OnExitPage  s    rU   rW  )r   r   r   r   rT   r  rN  rO  rV  r8  r:  r   rU   rS   r<   r<     s,    <I,"
1Kf&P rU   r<   c                       e Zd ZdZd Zd Zy)r4   z%Shows summary result of choosing datac                    t        j                  | |t        d             || _        t	        | t
        j                  t        d            | _        t	        | t
        j                  d      | _        | j                  j                  | j                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  t        d	            | _        t	        | t
        j                  d      | _        | j                  j                  | j                  dd
t
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  t        d            | _        t	        | t
        j                  d      | _        | j                  j                  | j                   ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j"                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  t        d            | _        t	        | t
        j                  d      | _        | j                  j                  | j$                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j&                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _        t	        | t
        j                  d      | _        | j                  j                  | j(                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j*                  ddt
        j                  t
        j                  z  t
        j                  z         | j-                  t.        j0                  | j2                         t	        | t
        j                  t        d            | _        t	        | t
        j                  d      | _        | j                  j                  | j4                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j6                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _        t	        | t
        j                  d      | _        | j                  j                  | j8                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j:                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _        t	        | t
        j                  d      | _        | j                  j                  | j<                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | j>                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _         t	        | t
        j                  d      | _!        | j                  j                  | j@                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | jB                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _"        t	        | t
        j                  d      | _#        | j                  j                  | jD                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | jF                  ddt
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _$        t	        | t
        j                  d      | _%        | j                  j                  | jH                  ddt
        j                  t
        j                  z  t
        j                  z         | j                  j                  | jJ                  dd t
        j                  t
        j                  z  t
        j                  z         t	        | t
        j                  d      | _&        t	        | t
        j                  d      | _'        | j                  j                  | jL                  dd!t
        j                  t
        j                  z  t
        j                  z         | j                  j                  | jN                  dd"t
        j                  t
        j                  z  t
        j                  z         y )#NSummaryzConfiguration file name:r   r   r   r   r   r   zRaster name:r   r  zVector name:r  r  zRegion type:r  r  r  rn  zSampling area type:r  r  r  )r  r   )   r   )ro  r   )   r   )rp  r   )	   r   )rq  r   )r  r   )r  r   )   r   )rr  r   )(r  rT   r)   r    r	   r'   r(   	conflabelconftxtr  r  r  r  r  	rastlabelrasttxt	vectlabelvecttxtregionlabel	regiontxtregionkeylabelregionkeytxtr,  r6  r7  r8  samplinglabelsamplingtxt
shapelabelshapetxtshapewidthlabelshapewidthtxtshapeheightlabelshapeheighttxt
unitslabelunitstxtunitsmorelabelunitsmoretxtunitsmorelabel2unitsmoretxt2r>  s      rS   rT   zSummaryPage.__init__  sT   D&!I,7  $BIIQ/I-J
 ""))2F

NN!9!99BFFB	 	 	
 	

LL!9!99BFFB	 	 	
 $4BIIQ~EVW!"))2F

NN!9!99BFFB	 	 	
 	

LL!9!99BFFB	 	 	
 $4BIIQ~EVW!"))2F

NN!9!99BFFB	 	 	
 	

LL!9!99BFFB	 	 	
 &BIIQ~->
 $4BIIRH

!9!99BFFB	 	 	
 	

NN!9!99BFFB	 	 	
 )"M&dryyK

!9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
 			#--t/?/?@'BIIQ/D-E
 &TbiirJ

!9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
 %DRYYbI"$299BG

OO!9!99BFFB	 	 	
 	

MM!9!99BFFB	 	 	
  *"))2N't		L

  !9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
 !+$299B O("M

!!!9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
 %DRYYbI"$299BG

OO!9!99BFFB	 	 	
 	

MM!9!99BFFB	 	 	
 )"M&dryyK

!9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
  *"))2N't		L

  !9!99BFFB	 	 	
 	

!9!99BFFB	 	 	
rU   c           	         | j                   j                  | j                  j                  j                         | j
                  j                  | j                  j                  j                         | j                  j                  | j                  j                  j                         | j                  j                  | j                  j                  j                         | j                  j                  | j                  j                  j                         | j                  j                  j                  dk(  r| j                  j                  t        d             d| j                  j                   j"                  d| j                  j                   j$                  d| j                  j                   j&                  d| j                  j                   j(                  d	}| j*                  j                  |       n6| j                  j                  d       | j*                  j                  d       | j                  j                  j                  t,        j.                  k(  r| j                  j                  j0                  d	k(  r| j2                  j                  t        d
             | j4                  j                  | j                  j6                  j8                         | j                  j6                  j8                  dk(  rI| j:                  j                  t        d             | j<                  j                  t        d             nH| j:                  j                  t        d             | j<                  j                  t        d             | j>                  j                  | j                  j6                  j@                         | jB                  j                  | j                  j6                  jD                         | jF                  j                  t        d             | jH                  j                  | j                  j6                  jJ                         | j                  j6                  jJ                  dk(  r^| jL                  j                  t        d             | jN                  j                  | j                  j6                  jP                         y| j                  j6                  jJ                  dk(  r^| jL                  j                  t        d             | jN                  j                  | j                  j6                  jP                         y| j                  j6                  jJ                  dk(  r| jL                  j                  t        d             | jN                  j                  | j                  j6                  jP                         | jR                  j                  t        d             | jT                  j                  | j                  j6                  jV                         yy| j                  j                  j                  t,        j.                  k(  r| j                  j                  j0                  dk(  ry| j2                  j                  t        d
             | j4                  j                  | j                  j6                  j8                         | jH                  j                  d       y| j                  j                  j                  dk(  r| j2                  j                  t        d
             | j4                  j                  | j                  jX                  j8                         | j                  jX                  j8                  dk(  rI| j:                  j                  t        d             | j<                  j                  t        d             nH| j:                  j                  t        d             | j<                  j                  t        d             | j>                  j                  | j                  jX                  j@                         | jB                  j                  | j                  jX                  jD                         y| j2                  j                  d       | j4                  j                  d       | j:                  j                  d       | j>                  j                  d       | j<                  j                  d       | jB                  j                  d       y)r  rx   zRegion keyboard values:zColumn left up: z - Row left up: z
Column length: z - Row length: rz   r   r   zType of shape:r   zRadius size:zName circle mask:zWidth size:zHeight size:zMethod of distribution:r   zNumber sampling units:r   zDistance between units:r   zNumber row strates:zNumber column strates:r   zby mouser?   N)-rt  rS  r    r-   rH   rv  r^   r~  r3   r   rz  rk   rx  r   r{  r)   r1   r   r   r   r   r|  r   r   r   r  r  r7   r   r  r  r  r   r  r   r  r  r   r  r  r   r  r  r   r?   )rQ   rB  
regKeyValss      rS   r8  zSummaryPage.OnEnterPagec  sA    	dkk33==>dkk33889!!$++">">"K"KL 5 5 < <=dkk33889;;  ''50((+D)EF
 KK,,33KK,,33KK,,44KK,,44  &&z2((,&&r* KK((559K9KK,,66*DOO$$Q'7%89MM""4;;#4#4#<#<={{  ((H4$$--a.?@%%..q1D/EF$$--a.>?%%..q/@A''(9(9(?(?@(():):)A)ABOO$$Q'@%ABMM""4;;#4#4#>#>?{{  **.??##,,Q/G-HI!!**4;;+<+<+C+CD"",,0II##,,Q/H-IJ!!**4;;+<+<+C+CD"",,0CC##,,Q/D-EF!!**4;;+<+<+C+CD$$--a0H.IJ""++DKK,=,=,D,DE	 D KK((559K9KK,,66'AOO$$Q'7%89MM""4;;#4#4#<#<=MM"":.[[))66(BOO$$Q'7%89MM""4;;#5#5#=#=>{{!!))X5$$--a.?@%%..q1D/EF$$--a.>?%%..q/@A''(:(:(@(@A((););)B)BCOO$$R(MM""2&  ))"-''+!!**2.((,rU   N)r   r   r   r   rT   r8  r   rU   rS   r4   r4     s    /@
DN-rU   r4   )=r   rY   r'   core.globalvarr   r   r6  wx.advr   r   	wx.wizardwx.lib.scrolledpanellibscrolledpanelr  gui_corer   gui_core.wrapr   r	   r
   location_wizard.wizardr   r  rlisetup.functionsr   r   rlisetup.sampling_framer   grass.scriptr   rh   r   r\   r   r]  grass.exceptionsr   	functionsr   r   r   r   r   	core.gcmdr   r   r   objectr   r,   r0   r.   r2   r@   r6   r>   r8   r:   r<   r4   r   rU   rS   <module>r     s	  , 
 	 *   ' '  6 6 G 5 4 & ( ( .  3 2o, o,dH
 HVU:: U:p5:* 5:pt.
 t.n<j <LG0 G0Tj'J j'Zq0Z q0hO* OlS j S vS-* S-rU   