
    ը	f                    H   d Z ddlZddlZddlmZ ddlZddlmc mc m	Z
 ddlmZ ddlmZ ej                  rddlmZ n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 ddlm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl? ddl@ g dZA G d de      ZB G d de3      ZC G d de1e>e      ZD G d de*      ZE G d deE      ZF G d deE      ZG G d de4      ZH G d de4      ZI G d  d!e4      ZJ G d" d#eE      ZK G d$ d%eE      ZL G d& d'e*      ZM G d( d)eE      ZN G d* d+eE      ZO G d, d-eE      ZP G d. d/eE      ZQ G d0 d1eE      ZR G d2 d3eR      ZS G d4 d5eE      ZT G d6 d7eE      ZU G d8 d9eE      ZVy):a  
@package psmap.dialogs

@brief dialogs for wxPsMap

Classes:
 - dialogs::TCValidator
 - dialogs::PenStyleComboBox
 - dialogs::CheckListCtrl
 - dialogs::PsmapDialog
 - dialogs::PageSetupDialog
 - dialogs::MapDialog
 - dialogs::MapFramePanel
 - dialogs::RasterPanel
 - dialogs::VectorPanel
 - dialogs::RasterDialog
 - dialogs::MainVectorDialog
 - dialogs::VPropertiesDialog
 - dialogs::LegendDialog
 - dialogs::MapinfoDialog
 - dialogs::ScalebarDialog
 - dialogs::TextDialog
 - dialogs::ImageDialog
 - dialogs::NorthArrowDialog
 - dialogs::PointDialog
 - dialogs::RectangleDialog

(C) 2011-2012 by Anna Kratochvilova, and 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 Anna Kratochvilova <kratochanna gmail.com> (bachelor's project)
@author Martin Landa <landa.martin gmail.com> (mentor)
    N)deepcopy)ListCtrlAutoWidthMixin)	globalvar)	Validator)PyValidator)PilImageToWxImage)VectorDBInfo)Select)
RunCommandGErrorGMessage)SymbolDialog)BitmapButtonBitmapComboBoxBitmapFromImageButtonCheckBoxChoiceClientDCColourPickerCtrlDialogDirBrowseButtonEmptyBitmapExpandoTextCtrlFileBrowseButton	FloatSpinListBoxListCtrlNotebookOwnerDrawnComboBoxPanelRadioButtonRectScrolledPanelSpinCtrl	StaticBox
StaticTextTextCtrlTextEntryDialog
EmptyImageCheckListCtrlMixin)*)aquablackbluebrowncyangraygreygreenindigomagentaorangepurpleredvioletwhiteyellowc                   *    e Zd ZdZddZd Zd Zd Zy)TCValidatorz@validates input in textctrls, combobox, taken from wxpython demoNc                     t        j                  |        || _        | j                  t        j
                  | j                         y N)r   __init__flagBindwxEVT_CHAROnChar)selfrB   s     ./usr/lib/grass83/gui/wxpython/psmap/dialogs.pyrA   zTCValidator.__init__v   s-    4 			"++t{{+    c                 ,    t        | j                        S r@   )r>   rB   rG   s    rH   ClonezTCValidator.Clone{   s    499%%rI   c                     | j                         }|j                         }| j                  dk(  r|D ]  }|t        j                  vs y y)N
DIGIT_ONLYFT)	GetWindowGetValuerB   stringdigits)rG   wintcvalxs        rH   ValidatezTCValidator.Validate~   sH    ^^kkm99$ !FMM) ! rI   c                    |j                         }|t        j                  k  s|t        j                  k(  s|dkD  r|j	                          y | j
                  dk(  r/t        |      t        j                  dz   v r|j	                          y | j
                  dk(  rt        |      dv r|j	                          y t        j                         st        j                          y )N   rN   z.-ZERO_AND_ONE_ONLY01)
GetKeyCoderD   	WXK_SPACE
WXK_DELETESkiprB   chrrQ   rR   Validator_IsSilentBell)rG   eventkeys      rH   rF   zTCValidator.OnChar   s     !5sJJL99$SV]]T5I)IJJL 99++CD0@JJL$$&GGI 	rI   r@   )__name__
__module____qualname____doc__rA   rL   rW   rF    rI   rH   r>   r>   s   s    J,
&rI   r>   c                   (    e Zd ZdZd Zd Zd Zd Zy)PenStyleComboBoxz8Combo for selecting line style, taken from wxpython democ           
      Z   |t         j                  k(  ry t        | }|j                  dd       t         j                  }|dk(  rt         j
                  }n+|dk(  rt         j                  }n|dk(  rt         j                  }t        j                  |j                         d|      }|j                  |       |j                  | j                  |      |j                  dz   t        |j                  dz   |j                   dz  |j#                         z
  dz  z                |j%                  |j                  dz   t        |j                  |j                   dz  dz  z   dz         |j                  |j&                  z   dz
  t        |j                  |j                   dz  dz  z   dz                y )N            r      )rD   	NOT_FOUNDr#   DeflateSOLID	LONG_DASHDOTDOT_DASHPenGetTextForegroundSetPenDrawText	GetStringrV   intyheightGetCharHeightDrawLinewidth)rG   dcrectitemflagsrpenStylepens           rH   
OnDrawItemzPenStyleComboBox.OnDrawItem   sN   2<<$K			!Q8819||HQYvvHQY{{HffR))+Q9
		# 	NN4 CC!Gqahhlb.>.>.@@AEEF	

 	CC!G1)*Q./CC!''MA1)*Q./		
rI   c                    |dz  dk(  s$|t         j                  t         j                  z  z  rt        j                  | ||||       yt	        j
                  ddd      }|j                  t	        j                  |             |j                  t	        j                  |             t        j                  r|j                  |       y|j                  |       y)z`Overridden from OwnerDrawnComboBox, called for drawing the
        background area of each item.ro   r   N      )r    ODCB_PAINTING_CONTROLODCB_PAINTING_SELECTEDOnDrawBackgroundrD   ColourSetBrushBrushrz   rx   r   wxPythonPhoenixDrawRectangleDrawRectangleRect)rG   r   r   r   r   bgCols         rH   r   z!PenStyleComboBox.OnDrawBackground   s    
 !8q=E44 778
 //b$eL 		#sC(
BHHUO$
		"&&- $$T"  &rI   c                      y)z~Overridden from OwnerDrawnComboBox, should return the height
        needed to display an item in the popup, or -1 for default   ri   rG   r   s     rH   OnMeasureItemzPenStyleComboBox.OnMeasureItem        rI   c                      y)zdOverridden from OwnerDrawnComboBox.  Callback for item width, or
        -1 for default/undeterminedri   r   s     rH   OnMeasureItemWidthz#PenStyleComboBox.OnMeasureItemWidth   r   rI   N)re   rf   rg   rh   r   r   r   r   ri   rI   rH   rk   rk      s    B
@'*
rI   rk   c                       e Zd ZdZd Zy)CheckListCtrlzCList control for managing order and labels of vector maps in legendc                 J   t        j                  | |t        j                  t        j                  t        j
                  z  t        j                  z  t        j                  z  t        j                  z         t        j                  |        t        j                  |        y )Nidstyle)r   rA   rD   ID_ANY	LC_REPORTLC_SINGLE_SELBORDER_SUNKEN	LC_VRULES	LC_HRULESr+   r   )rG   parents     rH   rA   zCheckListCtrl.__init__   sz    yy,, ll ll				
 	##D)''-rI   N)re   rf   rg   rh   rA   ri   rI   rH   r   r      s
    M.rI   r   c                   L    e Zd ZddZd Zd Zd ZddZd Zd Z	d Z
d	 Zd
 Zy)PsmapDialogc           	         t        j                  | |t        j                  |t        j                  t        j
                  t        j                  z  t        j                  z         || _        || _	        || _
        || _        || _        d | _        t        |       | _        d| _        | j#                  t        j$                  | j&                         y )N)r   r   titlesizer   A   r   )r   rA   rD   r   DefaultSizeCAPTIONMINIMIZE_BOX	CLOSE_BOXapplyr   envr   instruction
objectTypeUnitConversionunitConvspinCtrlSizerC   	EVT_CLOSEOnClose)rG   r   r   r   settingsr   r   s          rH   rA   zPsmapDialog.__init__   s    yy**r.=	
 
#&t,$		",,-rI   c                    t               |_        t        |t        j                  t        d            |j                  d<   | j                  j                         }t        |t        j                  |      |j                  d<   |j                  d   j                  | j                  j                  |d                y )NzUnits:r   label
unitsLabelr   choices	unitsCtrlunit)dictunitsr'   rD   r   _r   getPageUnitsNamesr   SetStringSelectionfindName)rG   r   
dialogDictr   s       rH   AddUnitszPsmapDialog.AddUnits	  s    v%/299AhK%X\"--113$*6bii$Q[![!44MM"":f#56	
rI   c                    t        |d      st               |_        t        |t        j
                  t        d            |j                  d<   t        |t        j
                  t        d            |j                  d<   t        |t        j
                  t        d            |j                  d<   t        |t        j
                  t        |d	   d
         t        d            |j                  d<   t        |t        j
                  t        |d	   d         t        d            |j                  d<   d|v r| j                  j                  |d	   d
   d|d         }| j                  j                  |d	   d   d|d         }|j                  d   j                  d|z         |j                  d   j                  d|z         y y )NpositionzCPosition of the top left corner
from the top left edge of the paperr   commentzX:xLabelzY:yLabelwherer   rN   rB   r   value	validatorxCtrlro   yCtrlr   inchr   fromUnittoUnit%5.3f)hasattrr   r   r'   rD   r   r   r(   strr>   r   convertSetValue)rG   r   r   rV   r~   s        rH   AddPositionzPsmapDialog.AddPosition  s   vz*"fFO%/yyV&
	" %/v"))1T7$S!$.v"))1T7$S!#+yyj)!,-!|4	$
  $,yyj)!,-!|4	$
  Z%% )!,vjQWFX & A %% )!,vjQWFX & A OOG$--gk:OOG$--gk:  rI   c                    t               |_        t        |t        j                  t        d            }t        |t        j                  t        d      t        j                        |j                  d<   t        |t        j                  t        d            |j                  d<   |j                  d   j                  |d          |j                  d   j                  |d           |j                  |d	d
t        j                  t        j                  z  d       |j                  |j                  d   dt        j                  t        j                  z  d       |j                  |j                  d   dt        j                  t        j                  z  d       t        |t        j                  d      }t        j                  |t        j                        }t        j                  dd      | _        | j#                  ||       |j                  d   j%                  t        d             | j'                  ||       | j                   j                  |j(                  d   d	t        j                  d       | j                   j                  |j(                  d   dt        j                  d       | j                   j                  |j                  d   dt        j                  d       | j                   j                  |j                  d   dt        j                  d       | j                   j                  |j                  d   dt        j                  d       | j                   j                  |j                  d   dt        j                  d       | j                   j                  |j                  d   d d!t        j*                  d       | j                   j-                  d"       | j                   j/                  d#       |j                  | j                   d"t        j0                  t        j2                  z  d$       |j                  |ddt        j4                  t        j0                  z  d       t        |t        j                  d      }t        j                  |t        j                        }t        j                  dd      | _        t        |t        j                  d%      }	t        |t        j                  d&      }
t9        |t        j                  d'      |j                  d(<   t9        |t        j                  d'      |j                  d)<   t;        | j<                  | j>                     |d*   d   |d*   d"   d+| j@                  ,      \  }}|j                  d(   j                  tC        |             |j                  d)   j                  tC        |             | j6                  j                  |	d	t        j                  d       | j6                  j                  |
dt        j                  d       | j6                  j                  |j                  d(   dt        j                  d       | j6                  j                  |j                  d)   dt        j                  d       | j6                  j-                  d       | j6                  j-                  d"       |j                  | j6                  d"t        j0                  t        j2                  z  d$       |j                  |dt        j                  t        j0                  z  d       y-).z=Add widgets for setting position relative to paper and to mapzPosition is given:r   zrelative to paperr   r   r   toPaperzby map coordinatestoMapXYr   r   ro   rm   r   posspanrB   borderro   r   r   rB   r   ro   ro    r   r   r   rn   hgapvgapr   r   r   z,Position from the top left
edge of the paperr   r   r   ro   r   r   r   rp   r   r   rp   ro   rm   r   ro   rp   ro   rm   
proportionrB   r   E:N:r   r   eCtrlnCtrlr   TmapInstrrV   r~   
paperToMapr   N)"r   r   r'   rD   r   r   r"   RB_GROUPr   AddALIGN_CENTER_VERTICAL
ALIGN_LEFTr&   StaticBoxSizerVERTICALGridBagSizergridBagSizerPr   SetLabelr   r   ALIGN_BOTTOMAddGrowableColAddGrowableRowEXPANDALLALIGN_CENTER_HORIZONTALgridBagSizerMr(   PaperMapCoordinatesr   mapIdr   r   )rG   panelgridBagSizerr   positionLabelbox1sizerPbox2sizerMeastingLabelnorthingLabeleastnorths                rH   AddExtendedPositionzPsmapDialog.AddExtendedPosition4  s   "5RYYa@T>UV$/biiq)<'=R[[%
y! #.biiq)='>#
w 	y!**:d+;<w((Z-=)=>))BMM9 	 	
 	NN9%))BMM9	 	 	
 	NN7#))BMM9	 	 	
 "))2>""45__!!<*=y!**=>	
 	Uz:KK%))	 	 	
 	KK$))	 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN9% 	 	
 	))!,))!,

4%%!"))bff:LUV
W++bii7 	 	
 "))2>""45__!!<!%BIITB"5RYYdC"*5RYYb"Iw"*5RYYb"Iw)%%djj1!!$!!$
e 	w((T3w((U4f2+C+CA 	 	
 	vB,D,DQ 	 	
 	NN7#b6N6NWX 	 	
 	NN7#b6N6NWX 	 	
 	))!,))!,

4%%!"))bff:LUV
WV"--"))2KTUVrI   c                 x   t               |_        t        |t        j                  t        d            |j                  d<   t        |t        j                  t        d            |j                  d<   g d}t        |t        j                  |      |j                  d<   |d	   |v r"|j                  d   j                  |d	          n|j                  d   j                  d
       t        |t        j                  ddd      |j                  d<   |j                  d   j                  |d          |rt        |t        j                  t        d            |j                  d<   t        |t        j                        |j                  d<   |j                  d   j                  t        |d                y y )NzFont:r   	fontLabel
Font size:fontSizeLabel)zTimes-RomanzTimes-Italicz
Times-BoldzTimes-BoldItalic	HelveticazHelvetica-ObliquezHelvetica-BoldzHelvetica-BoldObliqueCourierzCourier-ObliquezCourier-BoldzCourier-BoldObliquer   fontCtrlfontr-  rq   2   
   r   minmaxinitialfontSizeCtrlfontsizezChoose color:
colorLabelr   	colorCtrlcolor)r   r0  r'   rD   r   r   r   r   r%   r   r   	SetColour
convertRGB)rG   r   r   r<  fontChoicess        rH   AddFontzPsmapDialog.AddFont  sY   f $.f!G*#UK '1ryy,(
O$
 #)BII{"SJf,KK
#66z&7IJKK
#66{C&.ryyaR'
N# 	N#,,Z
-CD(2299Ao,>)FKK% (8299'MFKK$KK$..z*W:M/NO rI   c                 v    | j                         }|r'| j                  j                  | j                         yy)Nr:  TF)updater   DialogDataChangedr   rG   rc   oks      rH   OnApplyzPsmapDialog.OnApply  s/    [[]KK))TWW)5rI   c                 L    | j                  |      }|r| j                          yy)zApply changes, close dialogN)rF  CloserD  s      rH   OnOKzPsmapDialog.OnOK  s!    \\% JJL rI   c                 $    | j                          y)zClose dialogN)rH  rG   rc   s     rH   OnCancelzPsmapDialog.OnCancel  s    

rI   c                     | j                   rA| j                   D ]2  }|| j                  j                  v s| j                  j                  |= 4 |j                          | j	                          y)z.Destroy dialog and delete it from open dialogsN)r   r   openDialogsr_   DestroyrG   rc   eachs      rH   r   zPsmapDialog.OnClose  sT    ?? 64;;222//56 	

rI   c                    t        | t        j                        }t        | t        j                        }|j	                          | j
                  rt        | t        j                        }|j                  t        j                  | j                         |j                  t        d             |j                  t        d             |j                  t        j                  | j                         | j
                  rDj                  t        j                  | j                         |j                  t        d             t        j                         }|j                  |       | j
                  r|j                         |j                  |       |j!                          t        j"                  t        j$                        }|j'                  |dt        j(                  t        j*                  z  d       |j'                  |dt        j(                  t        j*                  z  d       | j-                  |       |j/                          |j1                  |        y )NzClose dialog and apply changeszClose dialog and ignore changesApply changesro   rn   r  r   )r   rD   	ID_CANCELID_OK
SetDefaultr   ID_APPLYrC   
EVT_BUTTONrI  
SetToolTipr   rL  rF  StdDialogButtonSizer	AddButtonRealizeBoxSizerr  r  r  r  SetSizerLayoutFit)rG   r  	btnCancelbtnOKbtnApplybtnSizer	mainSizers          rH   _layoutzPsmapDialog._layout  s   4.	tRXX&::dBKK0H 	

2==$)),;<=Q@ABr}}dmm4::MM"--6/ 23 **,9%::x(5!KK,	e		BFF0B1Mh1299rvv3EaPi drI   NT)re   rf   rg   rA   r   r   r(  r@  rF  rI  rL  r   rf  ri   rI   rH   r   r      s:    .(
 ;DWB1Pv rI   r   c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	PageSetupDialogc                 L   t         j                  | ||d||       g d| _        t        d      t        d      t        d      t        d      t        d      t        d	      t        d
      t        d      t        d      g	}t	        t        | j                  |            | _        t        dddd      }| j                  |      | _	        | j                  j                         | _        ||   j                         | _        | j                          | j                  r| j!                  d      j#                  | j                  j%                  | j                  d                | j                  d   dk(  rA| j!                  d      j'                  | j!                  d      j)                         dz
         n-| j!                  d      j#                  | j                  d          | j                  d   dk(  r!| j!                  d      j'                  d       n | j!                  d      j'                  d       | j                  dd  D ]]  }| j                  j+                  | j                  |   d| j                  d         }| j!                  |      j-                  d|z         _ | j!                  d      j/                         | j!                  d      j)                         dz
  k7  r?| j!                  d      j1                          | j!                  d      j1                          n| j!                  d      j1                          | j!                  d      j3                  t4        j6                  | j8                         | j!                  d      j3                  t4        j6                  | j8                         | j!                  d      j3                  t4        j6                  | j8                         | j:                  j3                  t4        j<                  | j>                         y )Nz
Page setupr   r   r   r   r   )	UnitsFormatOrientationWidthHeightLeftRightTopBottomrl  rm  rn  ro  rp  rq  rr  rs  rt  zps.mappT)r   readquietcustomro   Portraitr   rm   r   r   %4.3f) r   rA   catr   r   zip
catsLabelsr   _toList
paperTabler   r   	unitsListGetInstructionpageSetupDictrf  getCtrlr   r   SetSelectionGetCountr   r   GetSelectionDisablerC   rD   
EVT_CHOICEOnChoicebtnOkrX  rI  )	rG   r   r   r   r   labelspaperStringr   rU   s	            rH   rA   zPageSetupDialog.__init__/  s*   BlXSV 	 	


 gJhKmgJhKfIgJeHhK

 s488V45 4tL,,{388:%b\88:LL!44&&t'9'9''BC !!(+x7X&33LL*3359 X&99$:L:LX:VW!!-0J>]+88;]+88; ;mm++,,T2#--g6 , 
 T"++GcM:; LL"//1||H%..0145 LL!))+LL"**,LL'//1W""2==$--@X##BMM4==A]#((F

tyy1rI   c                 l   | j                   j                  | j                  d      j                               | j                  d<   | j
                  | j                  d      j                            d   | j                  d<   | j                  d      j                         dk(  rd| j                  d<   nd| j                  d<   | j                  dd  D ]`  }| j                   j                  t        | j                  |      j                               | j                  d   d	      | j                  |<   b y )
Nrl  rm  rn  r   ry  	Landscaperm   r   r   )r   findUnitr  GetStringSelectionr  r  r  r{  r   floatrP   r   s     rH   rB  zPageSetupDialog.updatew  s   &*mm&<&<LL!446'
7# (,LL"//1(

(8$ <<&335:0:D}-0;D}-HHQRL 	D'+}}'<'<DLL.779:++G4 (= (Dt$	rI   c                     	 | j                          |j                          y # t        $ rL t        j                  t        d      t        d      t        j                  t        j                  z         Y y w xY w)NzLiteral is not allowed!Invalid inputmessagecaptionr   )rB  r_   
ValueErrorrD   
MessageBoxr   OK
ICON_ERRORrK  s     rH   rI  zPageSetupDialog.OnOK  sY    		KKM JJL  	MM34/*eebmm+	s   # AA87A8c                 
   d}t        j                  t         j                        }t        | t         j                  dt        d      z        }t        j                  |t         j                        }t        | t         j                  dt        d      z        }t        j                  |t         j                        }t        j                  t         j                        }| j                  | j                  D cg c]  }|d   	 c}t        d      t        d      gg}	g d	}
g d
}i | _
        t        | j                  d d       D ]  \  }}t        j                  t         j                        }t        | t         j                  | j                  |   dz         }t        | t         j                  |	|   |      }|j!                  ||
|   t         j"                  t         j$                  z  ||          |j!                  |dt         j$                  ||          |dk(  r|j!                  |d       || j                  |<    | j                  dd  D ]  }t        j                  t         j                        }t        | t         j                  | j                  |   dz         }t'        | t         j                  |d      }|j!                  |dt         j"                  t         j$                  z  d       |j!                  |dt         j(                  t         j$                  z  d       || j                  |<    t+        |g|gdz  z   |gdz  z         }t        | j                        D ]Y  \  }}||   j!                  | j                  |   dt         j,                  t         j.                  z  t         j0                  z  d       [ t        j2                         }t5        | t         j6                        | _        | j8                  j;                          |j=                  | j8                         t5        | t         j>                        }|j=                  |       |jA                          |j!                  |dt         j0                  t         j.                  z  t         jB                  z  d       |j!                  |dt         j0                  t         j.                  z  t         jB                  z  t         jD                  z  d       |j!                  |dd       |j!                  |dt         jF                  t         j$                  z  d       | jI                  |       |jK                  |        y c c}w )N)n   r    %s z	Page sizer   Marginsrm  ry  r  )r   ro   ro   )rn   rm   rm   rm   :r   r   r   r  r   rl  ro   r   )r   r   r   rq   rn   r2  r  r   )&rD   r]  r  r&   r   r   r  
HORIZONTALr  r  hBoxDict	enumerater{  r'   r}  r   r  r  r  r(   ALIGN_CENTRElistGROWRIGHTLEFTrZ  r   rU  r  rV  r[  rT  r\  BOTTOMr  ALIGN_RIGHTr^  r`  )rG   r   re  pageBox	pageSizer	marginBoxmarginSizerhorSizerr   r   proporr   ihBoxstTextchoicer   textctrlsizerrd  btns                        rH   rf  zPageSetupDialog._layout  s   KK,	DRYYfq~6MN%%gr{{;	dryy98MN	''	2;;?;;r}}- NN(,8T(^8z]AkN+

  "1. 	'GAt;;r}}-D$//$:ORU:UVFDRYY
NFHH!!9--6ay	   HHVvayHIwq!"&DMM$	'  HHQRL 	'D;;r}}-Dt		9NQT9TUERHHHH!"*B*BRVV*KTU   HHX!"//BFF2JSTHU"&DMM$	' i[I;?2k]Q5FFG * 	RGAt!HLLt,a2881Cbgg1MqQ	R **,D"((+


4::&T2<<(3!"''BHH*<ryy*HQS 	 	
 	288#bii/"));	 	 	
 	h1R8h12>>BFF3JSUVi dq 9s   :U.c                 ,   | j                   | j                  d      j                            }| j                  j	                  | j                  d      j                               }| j                  d      j                         }t               }| j                  dd  D ]/  }| j                  j                  t        ||         d|      ||<   1 d}|d   t        d      k7  rR|d	k(  r|d
   |d   c|d<   |d
<   | j                  dd  D ](  }| j                  |      j                  d||   z         * d}| j                  d      j                  |       | j                  d
      j                  |       | j                  d      j                  |        y )Nrm  rl  rn  rm   r   )r   r   Trx  ro   rp  ro  rz  F)r  r  r  r   r  r  r   r{  r   r  r   ChangeValueEnable)rG   rc   	currPapercurrUnitcurrOrientIdxnewSizer   enables           rH   r  zPageSetupDialog.OnChoice  sx   OODLL$:$G$G$IJ	==))$,,w*?*R*R*TU]3@@B&HHQRL 	D MM11io& 2 GDM	
 X!H+-!H%G$ 4 '("3  HT"..w/FGHFW$$V,X%%f-]#**v:6rI   c                 Z    | j                   |   j                  d      j                         S )Nro   )r  GetItemrO   r   s     rH   r  zPageSetupDialog.getCtrl  s%    }}T"**1-7799rI   c           	         t               }|j                         j                  d      D ]T  }t        t	        | j
                  d   g| j
                  dd  z   |j                                     }|j                  |       V i j                  | j
                  d   g| j
                  dd  z   d      }|j                  t        d             |j                  |       |S )N
ro   rm   d   rx  )rm  )
r  stripsplitr   r|  r{  appendfromkeysrB  r   )rG   paperStrsizeListlineds        rH   r~  zPageSetupDialog._toList  s    6NN$**40 	DS$((1+!"5tzz|DEAOOA	 KK!4c:	($rI   N)
re   rf   rg   rA   rB  rI  rf  r  r  r~  ri   rI   rH   ri  ri  .  s)    F2P$
DL70:rI   ri  c                   *    e Zd ZdZddZd Zd Zd Zy)	MapDialogzMDialog for map frame settings and optionally  raster and vector map selectionNc                    t         j                  | ||d||       || _        | j                  rd| _        nd| _        | j                  r}t	        | t
        j                  t
        j                        | _        t        | j                  | j                  d   | j                  ||d      | _        | j                  j                         | j                  d<   t        | j                  | j                  d	   | j                  |d
      | _        | j                  j                         | j                  d	<   t!        | j                  | j                  d   | j                  |d
      | _        | j"                  j                         | j                  d<   | j%                  | j                         | j'                  t)        d             y t        | | j                  d   | j                  ||d      | _        | j                  j                         | j                  d<   | j%                  | j                         | j'                  t)        d             y )Nr   rk  )mapNotebookmapr   r   r   r   T)r   r   r   r   r   notebookro   r   r   r   r   r  rp   zMap settingsFzMap frame settings)r   rA   
isNotebookr   r   rD   r   
BK_DEFAULTr  MapFramePanelr   r   mPanelgetIdRasterPanelrPanelVectorPanelvPanelrf  SetTitler   )rG   r   r   r   r   r   r  s          rH   rA   zMapDialog.__init__  s   Bb8 	 	
 #??.DO&DO ??$DRYYbmmTDM'}}771:))DK **,DGGAJ%}}771:))DK **,DGGAJ%}}771:))DK **,DGGAJLL'MM!N+,'771:))DK **,DGGAJLL%MM!012rI   c                 2   | j                   r| j                  j                         }| j                  j                         }|rD| j                  d   | j
                  v r)| j                  j                  | j                  d          |rD| j                  d   | j
                  v r)| j                  j                  | j                  d          |r|sy| j                  j                         }|r*| j                  j                  | j                  d          yy)rS  rp   r:  ro   Fr   T)	r  r  rB  r  r   r   r   rC  r  )rG   rc   okVokRrE  s        rH   rF  zMapDialog.OnApply:  s    ??++$$&C++$$&CtwwqzT%5%55---<twwqzT%5%55---<c[[!KK))TWWQZ)8rI   c                    | j                   j                  j                  j                  | j                   j                  j                         | j                   j                  j                          | j                          y)z#Close dialog and remove tmp red boxN)r   canvaspdcTmpRemoveIdidZoomBoxTmpRefreshrH  rK  s     rH   rL  zMapDialog.OnCancelM  sO    !!**4;;+=+=+J+JK""$

rI   c                    | j                   j                  j                         dk(  r| j                   j                  j	                         r d| j
                  j                  v r| j
                  j                  d   j                  j                  j	                         r| j
                  j                  d   j                  j                  j	                         | j                   j                  j	                         k(  r&| j                   j                  j                  d       y| j                   j                  j                  d       yyd| j
                  j                  v rd}| j
                  j                  d   j                  j                  D ]/  }|d   | j                   j                  j	                         k(  s.d}1 | j                   j                  j                  |       yyy)z$Update raster and vector informationr   rasterTFvectorN)r  scaleChoicer  rasterTypeRadiorP   r   rN  r  rasterYesRadiorasterSelectselectdrawMapr   r  
vectorList)rG   foundrQ  s      rH   updateDialogzMapDialog.updateDialogS  sq   ;;""//1Q6{{**335t{{666//$ &
; !KK33$ &hhj;;--6689
 ++44T:++44U; 7 t{{666!E $ 7 7 A H H S S )7dkk&8&8&A&A&CC$(E) KK''007 7! 7rI   )NF)re   rf   rg   rh   rA   rF  rL  r  ri   rI   rH   r  r    s    W43l&8rI   r  c                   B    e Zd ZdZddZd Zd Zd Zd Zd Z	d Z
d	 Zy
)r  z/Panel with map (scale, region, border) settingsc                    t        j                  | |t        j                  t        j                         || _        || _        || _        |rM|| _        | j                  j                  | t        d             | j                  j                         | _        n|| _        | j
                  -| j                  | j
                     j                         | _        nTt               | _        t!        | j
                  | j                        }|j                         | _        || j                  d<   | j#                          d gdz  | _        d gdz  | _        | j                  d   | _        | j                  d   | _        | j                  d	   | _        | j                  d
   | _        | j0                  j3                  | j                  d	          | j                  | j
                     r)| j4                  j7                  | j                  d          n| j4                  j7                  d       | j                  d	   dk(  r| j                  d   r| j8                  j7                  | j                  d          | j                  d
   dk(  r7| j:                  j7                  d       | j<                  j7                  d       n| j:                  j7                  d       | j<                  j7                  d       nI| j                  d	   dk(  r7| j                  d   r(| j8                  j7                  | j                  d          | j?                  d        | j                  d   | j$                  | j                  d	   <   | j                  d   | j&                  | j                  d	   <   | jA                  d        | jC                  d        | jE                  d        y )Nr   	Map framepagetextr   r   rq   r  region	scaleTypemapTyper  Tr   r  Fro   scalecenter)#r!   rA   rD   r   TAB_TRAVERSALr   r   r   bookAddPager   	GetParent	mapDialogr  mapFrameDictNewIdMapFramerf  r   r  selectedMapselectedRegionr  r  r  r  r  r   r  r  vectorTypeRadioOnMapOnScaleChoiceOnElementTypeOnBorder)rG   r   r   r   r   r   r  mapFrames           rH   rA   zMapFramePanel.__init__p  s   tV		9I9IJ#DIII4an=!YY002DN#DN77 $ 0 0 9 H H JDgDGTXX6H ( 7 7 9D(,Df%VaZ
fqj,,U3"//9**;7((3%%d&7&7&DEDGG$LL!!$"3"3I">?LL!!$'[)Q.43D3DU3KKK  !2!25!9:  +x7$$--d3$$--e4$$--e4$$--d3{+q0T5F5Fx5PKK  !2!28!<=

4595F5Fw5O

4$$[126:6G6G6QD%%k234 4 drI   c           	         t        j                  t         j                        }t        | t         j                  dt        d      z        }t        j                  |t         j                        }t        j                  dd      }t        | t         j                  t        d            }t        d      t        d	      t        d
      t        d      g}t        | t         j                  |      | _        |j                  |dt         j                  d       |j                  | j                  dt         j                  t         j                  z  d       t        | t         j                  dt        d      z        | _        t        j                  | j                  t         j                        }t        j                  dd      | _        t#        | t         j                  dt        d      z  t         j$                        | _        t#        | t         j                  dt        d      z        | _        t+        | t         j                  d      | _        t        d      t        d      g| _        t1        |       }t3        |j5                  | j.                  d         d   |j5                  | j.                  d         d         }	t        | t         j                  | j.                  d   |	df      | _        t9        | t         j                  t:        j<                  dddd      | _        | j                   j                  | j&                  dt         j                  d       | j                   j                  | j(                  d t         j                  d       | j                   j                  | j,                  d!t         j                  t         j@                  z  d       | j                   j                  | j6                  dt         j                  d       | j                   j                  | j>                  d"d#t         j                  d$       |j                  | j                   dt         j                  t         jB                  z  d%       |j                  |d&t         j                  t         j                  z  d       t        | t         j                  dt        d'      z        }
t        j                  |
t         j                        }t        jD                  d(ddd)      | _#        t        | t         j                  t        d*            }t        | t         j                  t        d+            | _$        t        | t         j                  t        d,            | _%        tM        | t         j                  t         jN                  tQ        d-.      /      | _)        tM        | t         j                  t         jN                  tQ        d-.      /      | _*        t        | t         j                  t        d0            }t        | t         j                  t        d1            }tM        | t         j                  d2t         jN                  tQ        d-      3      | _+        | jF                  j                  |dt         j                  t         jX                  z  d4%       | jF                  j                  | jH                  dt         j                  t         j@                  z  d%       | jF                  j                  | jR                  dt         j                  d%       | jF                  j                  | jJ                  dt         j                  t         j@                  z  d%       | jF                  j                  | jT                  dt         j                  d%       | jF                  j                  |dt         j                  t         jX                  z  d4%       | jF                  j                  |dt         j                  t         j@                  z  d%       | jF                  j                  | jV                  dt         j                  d%       |j                  | jF                  dt         j                  t         jB                  z  d%       |j                  |d5t         j                  t         j                  z  d       t        jD                  dd(dd)      }t        | t         j                  t        d6            }t[        | t         j                  dd7d89      | _.        |j                  |dt         j                  d%       |j                  | j\                  dt         j                  d%       | j\                  j_                  | j`                  d:          |j                  |d;t         j                  t         j                  z  d       |j                  |dt         j                  t         jB                  z  d%       |j                  |dt         jB                  t         j                  z  d%       t        | t         j                  dt        d<      z        }t        j                  |t         j                        }t        j                  dd      }t+        | t         j                  t        d=            | _1        | j`                  d>   d?k(  r| jb                  j_                  d       n| jb                  j_                  d       t        | t         j                  t        d@            | _2        t        | t         j                  t        dA            | _3        ti        | t         j                  B      | _5        t[        | t         j                  ddCd9      | _6        | j`                  d>   d?k(  rb| jl                  j_                  to        | j`                  dD                | jj                  jq                  ts        | j`                  dE                |j                  | jb                  ddFt         j                  t         j                  z  d$       |j                  | jd                  d"t         j                  d       |j                  | jf                  dGt         j                  d       |j                  | jj                  dFt         j                  t         j                  z  d       |j                  | jl                  dHt         j                  t         j                  z  d       |j                  |dt         j                  t         jB                  z  d%       |j                  |dt         jB                  t         j                  z  d%       | ju                  |       | jw                          ty               dI   dJk(  r| j                  j{                  | j                  j}                         ddK        |
j                          | jF                  j                         D ]   }|j                         j                          " | j                  j                  t         j                  | j                         | j                  t         j                  | j                  | j(                         | j                  t         j                  | j                  | j&                         | j                  t         j                  | j                  | jb                         y)L	Do layoutr  r  r   rn   r   zMap frame options:r   zfit frame to match selected mapzfit frame to match saved regionz/fit frame to match current computational regionzfixed scale and map centerr   r   r   r   r   Map selectionr  r   r  zadd selected mapMap:zRegion:ro   r   )r   r   r   FTNr   r   typemultipleupdateOnPopuponPopupr   r   rp   )r   rm   r   r   r   r  r   zMap scale and centerrp   rowscolsr   r   zCenter:r  r  rN   r   )r   r   r   Scale:z1 :r   )r   r   r   r   r2  r   zMap max resolution (dpi):i  i,  r3  
resolutionrq   r   Borderzdraw border around map framer   r~   zborder color:zborder width (pts):r:  r  r   r<  r   r   rp   rp   projllrm   )IrD   r]  r  r&   r   r   r  r  r  r'   r   r  r  r  r  	staticBoxmapSizerr"   r  r  r  r   r  mapOrRegionTextr   r5  GetTextExtentmapTextr
   r   DIALOG_GSELECT_SIZEr  r  r  FlexGridSizercenterSizereastingTextnorthingTextr(   TE_RIGHTr>   eastingTextCtrlnorthingTextCtrlscaleTextCtrlr  r%   resolutionSpinr   r  borderCheckborderColorTextborderWidthTextr   borderColourPickerborderWidthCtrlr}   r=  r>  r^  r`  projInfoSetItemsGetItemsHideGetChildrenrO   rC   r  r  EVT_RADIOBUTTONr  EVT_CHECKBOXr  )rG   r   boxr  r  	frameTextscaleChoicesr#  r   r   boxCsizerC
centerText	scaleTextscalePrefixText	flexSizerresolutionTextrQ  s                     rH   rf  zMapFramePanel._layout  s   R[[)t		!K.9PQ!!#r}}5AA6 t		;O9PQ	/0/0?@*+	
 "$299lKR5M5MVWX))BII5	 	 	
 #BIIVa6H-H
 ""4>>2==AQQ7*RYYfq{&:"++ 
  +RYYfq{&: 
  :LM !&	1Y<8d^T11!45a8T11!45a8
 "RYYd&:&:1&=UBK
 yy..
 	  f23K3KTU 	 	
 	  f23K3KTU 	 	
 	LL))BNN:	 	 	
 	LLf2+C+CA 	 	
 	KK)) 	 	
 	

4==QRYY5GPQ
RR%=%=		%IRS 	 	

 BIIVa8N6O-O
 ""47++K!I,G
%dryy$H&t		4I'yy++!|4	 
 !)yy++!|4	!
 t		8E	$TbiiqxH%yy++!,/
 	))BHH4	 	 	
 	))BNN:	 	 	
 	  QR5M5MVW 	 	
 	))BNN:	 	 	
 	!!ab6N6NWX 	 	
 	!"*B*BRXX*MVX 	 	
 	))BNN:	 	 	
 	123K3KTU 	 	
 	

4##		BFF8JST
UR%=%=		%IRS 	 	

 $$!!!!D	#RYYa(C&D
 't		qdTWXqr/G/GPQ 	 	
 	AB4L4LUV 	 	
 	$$T%6%6|%DE6(@(@299(LUV 	 	
 			,1299rvv3Ea	P

5QRVVbii-?
J t		!H+9MN!!#r}}5AA6#RYYq)G'H
 X&#-%%d+%%e,)$299AoDVW)RYYa(=&> 
 #34BII"F'sTUVX&#-  ))#d.?.?.H*IJ##--j9J9J79S.TU))BII5 	 	
 	  f23K3KTU 	 	
 	  f23K3KTU 	 	
 	##))BII5	 	 	
 	  ))BII5	 	 	
 			,1299rvv3Ea	P

5QRVVbii-?
Jf
:f%%%d&6&6&?&?&A!A&FGIIK((446 ( %%'( 	bmmT-?-?@		"$$d&8&8$:N:NO		"$$d&8&8$:N:NO		"//4==$2B2BCrI   c                    | j                   j                         r | j                   j                         | _        nd| _        | j                  j	                         dk(  r| j                  | _        | j                  j                         rd}nd}t        | d| j                  || j                  d   | j                        \  | j                  d<   | j                  d<   }n| j                  j	                         dk(  ra| j                  | _        t        | d| j                  | j                  d   | j                        \  | j                  d<   | j                  d<   }n| j                  j	                         d	k(  rEt        | d	| j                  d   | j                  
      \  | j                  d	<   | j                  d	<   }nd| j                  d<   d| j                  d<   | j                  d       y)zSelected map or region changingNr   r  r  r   )r  r  r  r   r   ro   r  r  r   r   rp   r  r   r   rm   )r  rP   selectedr  r  r
  r  
AutoAdjustr  r   r   r  r  r  )rG   rc   r  foos       rH   r  zMapFramePanel.OnMap  s    ;;! KK002DM DM((*a/#}}D##,,.""1;MM&&v.HH2.DJJqM4;;q>3 **,1"&--D1;}}&&v.HH2.DJJqM4;;q>3 **,11;(9(9&(Atxx2.DJJqM4;;q>3 !DJJqM!DKKN4 rI   c                    | j                   j                         }| j                  |k7  r"|| _        | j                  j	                  d       |dv r|dk(  r| j
                  j                          | j                  j                          | j                  j                          | j                  j                  dt        d      z         | j
                  j                         rd}nd}| j                  j                  |       | j                  j                  | j                  d          | j                  j!                  t        d	             |d
k(  r| j
                  j#                          | j                  j#                          | j                  j#                          | j                  j                  dt        d      z         d}| j                  j                  |       | j                  j                  | j                  d
          | j                  j!                  d       | j$                  j'                         D ]   }|j)                         j+                          " | j,                  j'                         D ]   }|j)                         j/                          " | j0                  |   r.| j2                  j	                  dd
| j0                  |   z  z         | j4                  |   ri| j6                  j	                  t9        | j4                  |   d                | j:                  j	                  t9        | j4                  |   d
                yy|dk(  r0| j$                  j'                         D ]   }|j)                         j/                          " | j,                  j'                         D ]   }|j)                         j/                          " | j0                  |   r.| j2                  j	                  dd
| j0                  |   z  z         | j4                  |   ri| j6                  j	                  t9        | j4                  |   d                | j:                  j	                  t9        | j4                  |   d
                yy| j$                  j'                         D ]   }|j)                         j/                          " | j,                  j'                         D ]   }|j)                         j+                          " | j0                  |   r.| j2                  j	                  dd
| j0                  |   z  z         | j4                  |   ri| j6                  j	                  t9        | j4                  |   d                | j:                  j	                  t9        | j4                  |   d
                yy)zSelected scale type changingr   r   r   r  r  r  r  r  zIRegion is set to match this map,
raster or vector map must be added laterro   zRegion selectionr  z%.0frp   N)r  r  r  r  r   r  Showr  r  r&  r  r   rP   SetElementListr*  r(  rY  r=  r'  r>  rO   r  r-  r  r   r3  r  r1  r   r2  )rG   rc   r  styperQ  s        rH   r  zMapFramePanel.OnScaleChoice  s    $$113	>>Y&&DNKK  $A~$$))+$$))+!!#''?1C(CD''002$E$E***6%%d&:&:1&=>&&d A~$$))+$$))+!!#''3E1F(FG ***6%%d&:&:1&=>&&r*113 * '')*((446 + ((*+ zz)$""++Fa$**Y:O6O,PQ{{9%$$--c$++i2H2K.LM%%..s4;;y3I!3L/MN & !^113 + ((*+((446 + ((*+ zz)$""++Fa$**Y:O6O,PQ{{9%$$--c$++i2H2K.LM%%..s4;;y3I!3L/MN & 113 + ((*+((446 * '')* zz)$""++Fa$**Y:O6O,PQ{{9%$$--c$++i2H2K.LM%%..s4;;y3I!3L/MN &rI   c                     | j                   j                         rd}nd}| j                  j                  |       | j                  |k7  r$|"|| _        | j                  j                  d       || _        y)z-Changes data in map selection tree ctrl popupr  r  rR  Nr   )r  rP   r  rT  r  r   )rG   rc   r  s      rH   r  zMapFramePanel.OnElementType  sd    ((*GG"""0<<7"u'8"DLKK  $rI   c                     | j                   | j                  | j                  | j                  fD ]+  }|j	                  | j
                  j                                - y)z8Enables/disable the part relating to border of map frameN)r6  r7  r8  r9  r  r5  rP   rP  s      rH   r  zMapFramePanel.OnBorder(  sV         ##  	
 	5D KK((1134	5rI   c                     | j                   S )zReturns id of raster mapr:  rK   s    rH   r  zMapFramePanel.getId2  s    wwrI   c           	         t        | j                        }| j                  j                         |d<   | j                  }||d<   |d   dk(  r| j
                  j                         r+| j                  j                         |d<   | j
                  j                         |d<   | j                  |d<   d|d<   |d   r8|d   d	k(  rt        j                  |d   d
      }|d   dk(  rt        d|d   z         y| j                  j                  d	      }|r
|d   |d	<   nt        t               | j                        }|d   |d	<   d|d<   | j                  j!                  |       n|d   dk(  rt        j                  |d   d      }|d   dk(  rt        d|d   z         y| j                  j                  d      }d}|r|d   D ]  }|d   |d   k(  sd} |st        j"                  |d         }|rt%        |d         rd}	nt%        |d         rd}	nd}	dj'                  |d   j)                  d            dz   }
|s?t+        t               | j                        }g |d<   | j                  j!                  |       t               }|d   j-                  d|d   |	|d|
g       t/        ||	| j                        }|d   |
dc|d<   |d<   |d <   | j                  j!                  |       nyt1        | d|d   | j                  | j                  | j                  d!   "      \  | j2                  d<   | j4                  d<   | _        | j6                  r| j6                  |d!<   n| j                  d!   |d!<   | j2                  d   |d#<   | j4                  d   |d$<   | j                  d	k(  r1t        j8                  |d   | j                  %      | j                  d&<   | j                  dk(  r| j                  j                  d	      }|r|j:                  }nd}|rDt        j8                  |d   | j                  |   d	   | j                  '      | j                  d&<   n*t        j8                  |d   | j                  (      | j                  d&<   nt=        j>                  tA        d)      tA        d*      t<        jB                  t<        jD                  z  +       y|d   dk(  rb| j
                  j                         rd|d<   d|d<   d|d<   | j
                  j                         |d<   t1        | d|d   | j                  d!   | j                  ,      \  | j2                  d<   | j4                  d<   | _        | j6                  r| j6                  |d!<   n| j                  d!   |d!<   | j2                  d   |d#<   | j4                  d   |d$<   t        j8                  |d   | j                  -      | j                  d&<   nt=        j>                  tA        d.      tA        d*      t<        jB                  t<        jD                  z  +       y|d/k(  rd|d<   d|d<   d|d<   d|d<   t1        | d/| j                  d!   | j                  0      \  | j2                  d/<   | j4                  d/<   | _        | j6                  r| j6                  |d!<   n| j                  d!   |d!<   | j2                  d/   |d#<   | j4                  d/   |d$<   t        jF                  d      }| j                  j                  d	      }|r|j:                  }nd}|rOt        j8                  |d1   |d2   |d3   |d4   | j                  |   d	   | j                  5      | j                  d&<   nt        j8                  |d1   |d2   |d3   |d4   | j                  6      | j                  d&<   n|d7k(  rd|d<   d|d<   d|d<   d|d<   | j                  d!   |d!<   	 tI        | jJ                  j                               }tI        | jL                  j                               }tI        | jN                  j                               }d|z  |d#<   ||f|d$<   tU        | || j                  9       tW        |d   |d!   jX                  |d!   jZ                  | j                  :       | j\                  j                         rd;|d<<   nd1|d<<   |d<   d;k(  rC| j^                  j                         |d=<   ta        | jb                  je                               |d><   | j:                  | j                  vr<tg        | j:                  | j                        }| j                  j!                  |       | j                  | j:                     ji                  |       | j:                  | jj                  jl                  jn                  vr:| jj                  jl                  jn                  j-                  d| j:                         y# tP        tR        f$ rL t=        j>                  tA        d8      tA        d*      t<        jB                  t<        jD                  z  +       Y yw xY w)?zSave changesr   r  r   r  r  r  Nr  r  cellelementfiler   zRaster %s not foundFr  TisRasterr  zVector %s not foundr  r  areaslinespoints(@)ro   namer   lposr   )r  r  r   r  r   r   r  )r  r   GRASS_REGION)r  r  r   )r  r   zNo map selected!r  r  rL  )r  r   zNo region selected!rp   rM  nsew)rh  ri  rj  rk  r  r   )rh  ri  rj  rk  r   rm   zInvalid scale or map center!)mapDictr   )dpir   r   r   r~   r   r   r<  )8r   r  r4  rP   r  r  r  r  grass	find_filer   r   FindInstructionByTypeRasterr  r   AddInstructionvector_info_topobooljoinr  VectorinsertVPropertiesrO  r   r  rectAdjusted
region_envr   rD   r  r   r  r  r  r  r3  r1  r2  r  SyntaxErrorComputeSetRegionSetResolutionr   r   r5  r9  r>  r8  	GetColourr	  SetInstructionr  r   objectId)rG   r  r  mapFiler  r  isAddedrQ  topoInfotopoTyper   r   vProprasterIdr  scaleNumbercenterEcenterNr  s                      rH   rB  zMapFramePanel.update6  s	   D--.%)%8%8%A%A%C\"NN	$-[!$){{##%*.,,*?*?*AY'&*kk&:&:&<U#*.,,Y')-X&	*#I.(:"'//,u2Ev"V"6?b0$%:\%=P%PQ#(!%!1!1!G!G!Q!/;E/BF8,%+EG%BF/;E/BF8,15F:. ,,;;FC%i0H<"'//,u2Ex"X"6?b0$%:\%=P%PQ#(!%!1!1!G!G!Q"'!(.v 3#'7l5.A#A.2G3  '','='=,uBU'VH'#'(9#:/6H%)(7*;%</6H/7H(+e1D1J1J31O(PSV(V'--3EG-JF57F6N$($4$4$C$CF$K%*W &v 5 5$%U(;Xr1e'T!" )4Bdhh(O$0$7$)$% !MfuW~uV}
 !% 0 0 ? ? F',CM$U+ LL**62D@

1t{{1~t/@ $$+/+<+<L(+/+<+<V+DL((,

1W%)-QX&<<8+/4/?/?+E20DHH^, <<8+!--CCHMF#)99#'383C3C#/#6#'#3#3H#=h#G $40 493C3C#/#6DHH40
 01o.%%"--/
 +&!+{{##%*/Y'&*U#*.Y')-)=)=)?X&CM'1**62D@

1t{{1~t/@ $$+/+<+<L(+/+<+<V+DL((,

1W%)-QX&+0+;+;'1txx,( 34o.%%"--/
 !^&+L#"&L&*L#%)L"?I(9(9&(Atxx@<DJJqM4;;q>4+<   '+'8'8V$'+'8'8'@V$$(JJqML!%)[[^L"\\d+F%%;;HEF!99+0+;+;SkSkSkSk++H5h?,( ,1+;+;SkSkSkSk,( !^&+L#"&L&*L#%)L"#'#4#4V#<L 
#D$6$6$?$?$AB 4 4 = = ?@ 5 5 > > @A %&OL!%,g%5L"T<TXXF 	\*v&,,'..		
 $$&%(L"%(L"!S($($8$8$A$A$CL!$.t/F/F/P/P/R$SL!77$***TXX6H++H5!00>77$..//888NN!!**11477 M , <=o.%%"--/
 s   :A)h Ai.-i.Nrg  )re   rf   rg   rh   rA   rf  r  r  r  r  r  rB  ri   rI   rH   r  r  m  s6    94l}D~-!^FOP
5qrI   r  c                   0    e Zd ZdZddZd Zd Zd Zd Zy)	r  zPanel for raster map settingsc                 n   t        j                  | |t        j                  t        j                         || _        || _        |rM|| _        | j                  j                  | t        d             | j                  j                         | _        n|| _        |r4|| _        | j
                  | j                     j                         | _        nEt               | _        t!        | j                  | j                        }|j                         | _        | j#                          | j%                  d        y )Nr   z
Raster mapr  r  )r!   rA   rD   r   r  r   r   r  r  r   r  
mainDialogr   r  
rasterDictr  rq  rf  OnRaster)rG   r   r   r   r   r  r  s          rH   rA   zRasterPanel.__init__-  s    tV		9I9IJ#DIII4ao>"ii113DO$DODG"..tww7FFHDOgDGDGG2F$335DOdrI   c           	         t        j                  t         j                        }t        | t         j                  dt        d      z        }t        j                  |t         j                        }t        j                  dd      }t        | t         j                  t        d      t         j                        | _
        t        | t         j                  t        d      	      | _        t        | t         j                  t        j                  d
ddd      | _        | j                   d   r_| j                  j#                  d       | j                  j#                  d       | j                  j#                  | j                   d
          n| j                  j#                  d       | j                  j#                  d       | j$                  j'                  d      j(                  }| j$                  |   d   rA| j$                  |   d   d
k(  r,| j                  j#                  | j$                  |   d          n| j                  j#                  d       |j+                  | j                  ddt         j,                  d       |j+                  | j                  dt         j,                  d       |j+                  | j                  dt         j,                  t         j.                  z  d       |j+                  |dt         j.                  t         j0                  z  d       |j+                  |dt         j0                  t         j.                  z  d       | j3                  t         j4                  | j6                  | j                         | j3                  t         j4                  | j6                  | j                         | j9                  |       | j;                          y)r  r  zChoose raster mapr   rn   r   zno raster mapr   zraster:r   r  FTNr  r^  r  r  r   r   r   r   r   r   r   r   ro   r  )rD   r]  r  r&   r   r   r  r  r"   r  rasterNoRadior  r
   r   r+  r  r  r   r   rp  r   r  r  r  r  rC   r?  r  r^  r`  )rG   r   rA  r  r  r  s         rH   rf  zRasterPanel._layoutC  s   R[[) BIIVa8K6L-L
 !!#r{{3AA6(RYYa&8
 *$299AiLQ"yy..
 ??:&((.''.&&tx'@A((/''-$$::5ADDE   '.$$U+I6(B !!**4+;+;E+B5+IJ!!**2.)) 	 	
 	V"2J2JST 	 	
 	))BII5	 	 	
 			,1299rvv3Ea	P

5QRVVbii-?
J 			"$$dmmT5G5GH		"$$dmmT5H5HIf
rI   c                 j    | j                   j                  | j                  j                                y)zEnable/disable raster selectionN)r  r  r  rP   rK  s     rH   r  zRasterPanel.OnRaster  s%      !4!4!=!=!?@rI   c                 >   | j                   j                  d      }|st        t        d             y | j                  j                         s| j                  j                         sUd| j                  d<   d | j                  d<   d|d<   | j                  | j                   v r'| j                   | j                  = nd| j                  d<   | j                  j                         | j                  d<   | j                  d   |d   k7  rd|d<   | j                   j                  d      }|sot        | j                  | j                  	      }| j                   j                  |       | j                   | j                     j                  | j                         n2| j                   |j                     j                  | j                         d| j                  j                  j                  v r1| j                  j                  j                  d   j!                          y)
Nr  zPlease, create map frame first.r  Fr^  r  r  Tr  )r   rp  r   r   r  rP   r  r  r   rq  r   rr  r  r  r   rN  r  )rG   r	  r  s      rH   rB  zRasterPanel.update  s   ##99%@Q@AB&&(0A0A0J0J0L*/DOOJ'(,DOOH%"'HYww$***$$TWW- +/DOOJ'(,(9(9(B(B(DDOOH%x(HY,??&+#%%;;HEFTXX6  //7  )88I  +::4??KDOO**666OO""..u5BBDrI   c                     | j                   S r@   r:  rK   s    rH   r  zRasterPanel.getId      wwrI   Nrg  )	re   rf   rg   rh   rA   rf  r  rB  r  ri   rI   rH   r  r  *  s"    ',DLA@rI   r  c                   d    e Zd ZdZddZd Zd Zd Zd Zd Z	d Z
d	 Zdd
ZddZd Zd Zd Zy)r  zPanel for vector maps settingsc                    t        j                  | |t        j                  t        j                         || _        || _        || _        i | _        | j                  j                  dd      }|D ]I  }t        | j                  |j                     j                               | j                  |j                  <   K |r(|| _        t        | j                  |   d         | _        nt               | _        g | _        | j                  j                  d      }|r|j                  | _        nd | _        | j#                          |rF| j
                  j%                  | t'        d             | j
                  j)                         | _        y y )	Nr   vPropertiesTr  r  vectorLegendzVector mapsr  )r!   rA   rD   r   r  r   r   r   tmpDialogDictrp  r   r   r  r   r  r  	vLegendIdrf  r  r   r  )	rG   r   r   r   r   r  vectorsr  vLegends	            rH   rA   zVectorPanel.__init__  s>   tV		9I9IJ#""88T8R 	F,0  +::<-Dvyy)	
 DG&t'7'7';F'CDDOgDG DO""88H$ZZDN!DNKKT-0@A++//1DK rI   c                    t        j                  t         j                        }t        | t         j                  dt        d      z        }t        j                  |t         j                        }t        j                  dd      }t        | t         j                  t        d            }t        | t         j                  dd	d
d      | _
        t        d      t        d      t        d      g}g d| _        t        j                  | t         j                  dt        d      z  |dt         j                        | _        t        | t         j                  t        d            | _        |j#                  |dt         j$                  d       |j#                  | j                  ddt         j$                  d       |j#                  | j                  dt         j&                  d       |j#                  | j                   dt         j(                  t         j*                  z  d       |j#                  |dt         j,                  t         j.                  z  d       |j#                  |dt         j.                  t         j,                  z  d       t        | t         j                  dt        d      z        }t        j                  |t         j                        }t        j                  dd      }t        | t         j                  t        d            }t1        | t         j                  g t         j2                  t         j4                  z         | _        t        | t         j                  t        d!            | _        t        | t         j                  t        d"            | _        t        | t         j                  t        d#            | _        t        | t         j                  t        d$            | _        | jA                  d%       |j#                  |dt         j$                  d       |j#                  | j6                  d&d't         j$                  t         j,                  z  d       |j#                  | j8                  dt         j$                  t         j,                  z  d       |j#                  | j:                  d(t         j$                  t         j,                  z  d       |j#                  | j<                  d)t         j$                  t         j,                  z  d       |j#                  | j>                  d't         j$                  t         j,                  z  d       |jC                  dd*       |jC                  dd       |j#                  |dt         j.                  d       |j#                  |dt         j.                  t         j,                  z  d       | jE                  t         jF                  | jH                  | j                          | jE                  t         jF                  | jJ                  | j<                         | jE                  t         jF                  | jL                  | j8                         | jE                  t         jF                  | jN                  | j:                         | jE                  t         jF                  | jP                  | j>                         | j                  jS                         jE                  t         jT                  | jV                         | jY                  |       | j[                          | jE                  t         j\                  | jP                  | j6                         y)+r  r  zAdd mapr   rn   r   r  r   r  FTN)r   r  r  r  r  ra  r`  r_  ra  r`  r_  z	Data Typerm   )r   r   r   majorDimensionr   r  r   r   r   r   r   r   r   ro   r  zManage vector mapsz*The topmost vector map overlaps the others)r   r   r   UpDownDeletezProperties...rN  r   )rq   ro   r   rm   ro   rp   )/rD   r]  r  r&   r   r   r  r  r'   r
   r  topologyTypeListRadioBoxRA_SPECIFY_COLS
vectorTyper   	AddVectorr  r  ALIGN_CENTERr  r  r  r  r   	LB_SINGLELB_NEEDED_SBlistboxbtnUpbtnDownbtnDelbtnPropupdateListBoxr  rC   rX  OnAddVectorOnDeleteOnUpOnDownOnPropertiesGetTextCtrlEVT_TEXTOnVectorr^  r`  EVT_LISTBOX_DCLICK)rG   r   rA  r  r  r  topologyTypeTrs          rH   rf  zVectorPanel._layout  sC   R[[) t		!I,9NO!!#r{{3AA6$299AfI>yy
 H+qz1W:> <++yy1[>)"$$
  !E(C60H0HQRSKK)) 	 	
 	f2??STUNNR__r~~-MVW 	 	
 			,1299rvv3Ea	P

5QRVVbii-?
J BIIVa8L6M-M
 !!#r{{3AA6RYYa(T&U
 RYY",,2P
 DRYYag>
dryy&	BTbiiq{Cdryy/8JKA&60H0HQRSLL))BII5 	 	
 	JJF)A)ABII)MVW 	 	
 	LL))BII5	 	 	
 	KKV"*B*BRYY*NWX 	 	
 	LL))BII5	 	 	
 	##Aq)##Aq)		,1266!	D

5QRVVbii-?
J		"--!1!14>>B		"--<		"--DJJ7		"--dll;		"--!2!2DLLA!&&r{{DMMBf
		"''):):DLLIrI   c           	         | j                   j                         }t        j                  |d      d   syt        j                  |      }|r| j
                  j                  dt        |d                | j
                  j                  dt        |d	         xs t        |d
                | j
                  j                  dt        |d   xs t        |d                      t        ddd      D ]:  }| j
                  j                  |      s| j
                  j                  |        n | j                  j                          yy)zDGets info about toplogy and enables/disables choices point/line/arear  r[  re  Nr  rp   r_  ro   
boundariesr`  r   	centroidsra  r   )r  rP   rn  ro  rs  r  
EnableItemrt  rangeIsItemEnabledr  r  SetFocus)rG   rc   vmapr  r   s        rH   r  zVectorPanel.OnVectorE  s    {{##%
  ))d3OO&&q$x/@*ABOO&&4./J48I3J OO&&4-Ihx6H1IJ aR( ??006OO006
 NN##% rI   c                 .   | j                   j                         }|rf|j                  d      d   }	 d|j                  d      d   z   dz   }| j                  j                         }| j                  |   }|d|}t               }d}	||z   }
| j                  j                  d||||	|
g       | j                          | j                  j                  |gd       t        ||| j                        }|j                         | j                   |<   || j                   |   d	<   | j                  j#                  d       | j                  j%                  d       | j&                  j)                          | j+                          y
y
# t        $ r d}Y Fw xY w)zAdds vector map to listrc  r   rb  ro   rd  r    - r  re  N)r  rP   r  
IndexErrorr  r  r  r  r  rw  
repositionr  InsertItemsrx  r   r  r  r  EnsureVisibler  r  enableButtons)rG   rc   r  mapnamemapsetidxttyperecordr   rf  r   r  s               rH   r  zVectorPanel.OnAddVector^  sh   {{##%jjoa(Gtzz#q11C7 //..0C))#.E"&.FBDf$EOO""1tUBe&DEOOLL$$fXq1 U9F%+%:%:%<Dr"-1Dr"6*LL%%a(LL&&q)LL!!# /   s   F FFc                 R   | j                   j                         r| j                   j                         }| j                  |   d   }| j                  |= | j                  |= t        |t        | j                              D ]/  }| j                  |   d   s| j                  |   dxx   dz  cc<   1 |t        | j                        dz
  k  r|}nt        | j                        dz
  }| j                  |       | j                   j                         r| j                  d       yyy)z Deletes vector map from the listrp   rm   ro   r  FN)
r  GetSelectionsr  r  r  r  lenr  IsEmptyr  )rG   rc   r   r   r  rN  s         rH   r  zVectorPanel.OnDeletez  s   <<%%',,++-C%a(B$""2&3DOO 45 /??1%a(OOA&q)Q.)/ S)A--t/!31||##%""5) & (rI   c                 t   | j                   j                         r| j                   j                         }|r8| j                  j	                  |dz
  | j                  j                  |             | j                  s| j                          |dkD  r| j                  |dz
         y| j                  d       yy)zMoves selected map to topro   r   r  N)	r  r  r  r  rw  popr  r  r  rG   rc   r   s      rH   r  zVectorPanel.OnUp  s    <<%%',,++-C&&sQw0C0CC0HI>>!Qw""S1W"6""A". (rI   c                    | j                   j                         r| j                   j                         }|t        | j                        dz
  k7  rT| j                  j                  |dz   | j                  j                  |             | j                  s| j                          |t        | j                        dz
  k  r| j                  |dz          y| j                  t        | j                        dz
         yy)zMoves selected map to bottomro   r  N)
r  r  r  r  r  rw  r  r  r  r  r  s      rH   r  zVectorPanel.OnDown  s    <<%%',,++-Cc$//*Q..&&sQw0C0CC0HI~~OO%S)A--""S1W"6""C,@1,D"E (rI   c                 t   | j                   j                         r| j                   j                         }| j                  |   d   }t	        | j
                  || j                  | j                  |         }|j                         t        j                  k(  r|j                          |j                          yy)z"Opens vector map properties dialogrp   )r   r  tmpSettingsN)r  r  r  r  VPropertiesDialogr   r  	ShowModalrD   rU  rB  rO  )rG   rc   r   r   dlgs        rH   r  zVectorPanel.OnProperties  s    <<%%',,++-C%a(B# ..r2	C }}"((*

KKM (rI   c                     | j                   j                  |       | j                  j                  |       | j                  j                  |       | j                  j                  |       y)z3Enable/disable up, down, properties, delete buttonsN)r  r  r  r  r  )rG   r  s     rH   r  zVectorPanel.enableButtons  sJ    

&!F#F#6"rI   Nc                 x   | j                   D cg c]  }|d   d|d    }}| j                  j                  |       | j                  j                         r| j	                  d       y | j	                  d       |7| j                  j                  |       | j                  j                  |       y y c c}w )Nr   r  ro   FT)r  r  Setr  r  r  r  )rG   rN  r   mapLists       rH   r  zVectorPanel.updateListBox  s    >BooNdQa1NN!<<!u%t$#))(3**84 $ Os   B7c                     t        t        | j                              D ]*  }| j                  |   d   s|dz   | j                  |   d<   , y)z?Update position in legend, used only if there is no vlegend yetrm   ro   N)r  r  r  )rG   r  s     rH   r  zVectorPanel.reposition  sG    s4??+, 	.Aq!!$()A"1%	.rI   c                     | j                   S r@   r:  rK   s    rH   r  zVectorPanel.getId  r  rI   c                    | j                   j                  dd      }|D ]  }| j                   |j                  =  | j                  | j                   v r| j                   | j                  = t        | j                        dkD  rt        | j                  | j                        }| j                   j                  |       |j                  dt        | j                        i       | j                  D ]s  }|d   }t        ||d   | j                        }| j                   j                  |       |j                  | j                  |          |d   |d	<   |d
   |d<   |d   |d<   u n/| j                  | j                   v r| j                   | j                  = d| j                  j                  j                  v r1| j                  j                  j                  d   j                          y)Nr  Tr  r   r  r  rp   ro   re  rq   r   rm   rf  r  )r   rp  r   r  r  rv  r   rr  r  r   rx  r  r   rN  r  )rG   r  r  r   r   vLayers         rH   rB  zVectorPanel.update  s   ""88T8R 	,F  +	,77d&&&  )t!#DGG2F++F3!!68DOO+D"EF  )!W$Radhh?  //7%%d&8&8&<=!%av"&q'w!%av) ww$***$$TWW-DKK&&222KK**51>>@rI   rg  r@   )re   rf   rg   rh   rA   rf  r  r  r  r  r  r  r  r  r  r  rB  ri   rI   rH   r  r    sK    (2@oJb&2!8*(/F #	5. rI   r  c                   $    e Zd Zd Zd Zd Zd Zy)RasterDialogc                 4   t         j                  | ||t        d      ||       d| _        t	        | | j
                  | j                  d| j                        | _        | j                  j                         | _        | j                  | j                         y )NzRaster map settingsrk  )r  F)r   r   r   r  r   )r   rA   r   r   r  r   r   r   r  r  rf  rG   r   r   r   r   s        rH   rA   zRasterDialog.__init__  s    )* 	 	
 &!ww%%
 ++##%T[[!rI   c                 >    | j                   j                         }|ryyNTF)r  rB  )rG   rE  s     rH   rB  zRasterDialog.update  s    [[!rI   c                 *   | j                         }|sy| j                  | j                  v r'| j                  j	                  | j                         y| j                  j                  d      j                  }| j                  j	                  |       y)NFr:  r  TrB  r   r   r   rC  rp  )rG   rc   rE  r  s       rH   rF  zRasterDialog.OnApply  sy    [[]77d&&&KK))TWW)5  $$::5ADDEKK))U)3rI   c                      yzUpdate information (not used)Nri   rK   s    rH   r  zRasterDialog.updateDialog       rI   Nre   rf   rg   rA   rB  rF  r  ri   rI   rH   r  r    s    ",
rI   r  c                   $    e Zd Zd Zd Zd Zd Zy)MainVectorDialogc                     t         j                  | ||t        d      ||       d| _        t	        | | j
                  | j                  |d      | _        | j                  j                         | _        | j                  | j                         y )NzVector maps settingsrk  )r  Fr  )
r   rA   r   r   r  r   r   r  r  rf  r  s        rH   rA   zMainVectorDialog.__init__-  s~    *+ 	 	
 &!DGGd.>.>CRW
 ++##%T[[!rI   c                 8    | j                   j                          y r@   )r  rB  rK   s    rH   rB  zMainVectorDialog.update>  s    rI   c                 $   | j                          | j                  | j                  v r'| j                  j	                  | j                         y| j                  j                  d      j                  }| j                  j	                  |       y)Nr:  r  Tr  )rG   rc   r  s      rH   rF  zMainVectorDialog.OnApplyA  sq    77d&&&KK))TWW)5  $$::5ADDEKK))U)3rI   c                      yr  ri   rK   s    rH   r  zMainVectorDialog.updateDialogJ  r  rI   Nr  ri   rI   rH   r  r  ,  s    ""rI   r  c                       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d Zd Zd Zd Zd Zd ZddZd Zd Zy)r  c                 ^   t        j                  | |       |}|| _        d| _        |D ]  }||d   k(  s|d   | _        |d   | _        ! | j                  t        d      | j                  z         d| _        	 t        | j                        | _
        | j                  j                  j                         | _        | j                  sd| _        g | _        | j                  d	   | _        t!        j"                  d
      }t         j$                  j'                  |dd      | _        g | _        t!        j,                  | j(                        D ]}  }t!        j,                  t         j$                  j'                  | j(                  |            D ];  }	| j*                  j/                  t         j$                  j'                  ||	             =  t         j$                  j'                  |ddd      | _        t3        | t4        j6                  t4        j8                        }
| j;                  |
      | _        | j?                  | j                         | j@                  | jB                  g| jD                  | jF                  g| j@                  | jH                  gd} || j
                     d   |
      | _%        | jM                  d        | j
                  dv r| jO                  d        | jQ                  d         || j
                     d   |
      | _)        | j
                  dk(  r3| jU                  d        | jW                  d        | jY                  d        | j
                  dk(  r| j[                  d        | j]                  |
       y # t        j                  $ r d| _        g | _        Y w xY w)Nr   r   rp   r   ro   z%s propertiesTFlayerGISBASEetcsymbolpaintpatternsr  )r  r  ra  r_  ra  r_  )/r   rA   vPropertiesDictr   
vectorNamer  r  r   
connectionr	   	mapDBInfolayerskeysrn  ScriptError	currLayerosgetenvpathru  
symbolPathsymbolslistdirr  patternPathr   rD   r   r  _DataSelectionPanelDSpanelEnableLayerSelection_ColorsPointAreaPanel_StylePointPanel_ColorsLinePanel_StyleLinePanel_StyleAreaPanelColorsPanel	OnOutlineOnFillOnColor
StylePanelOnSize
OnRotationOnSymbology	OnPatternrf  )rG   r   r   r  r  r  r   gisbasedirr   r  selectPanels               rH   rA   zVPropertiesDialog.__init__P  s   	

 
*$  	$DT!W}"&q' G		$ 	a(4??:; 	)$//:DN..//446DK {{#DODK--g6 ))I&'',,wx@::doo. 	?C**RWW\\$//3%GH ?##BGGLLf$=>?	? 77<<L 4BIIR]]K//9!!!91143H3HI++T-A-AB00$2F2FG

 5;tyy1!4X>t99++KKT3+dii03H=99 KKOOD!T"99NN4 XU    	#DODK	s   ;AN !N,+N,c                    t        | t        j                        }t        | t        j                        }|j	                          t        j
                         }|j                  |       |j                  |       |j                          t        j                  t        j                        }|j                  |dt        j                  t        j                  z  d       |j                  |dt        j                  t        j                  z  d       | j                  |       |j                          |j                  |        y )Nro   rn   r  r   )r   rD   rT  rU  rV  rZ  r[  r\  r]  r  r  r  r  r^  r_  r`  )rG   r  ra  rb  rd  re  s         rH   rf  zVPropertiesDialog._layout  s    4.	tRXX& **,9%5!KK,	e		BFF0B1Mh1299rvv3EaPi drI   c           
         t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }d x| _        | _	        | j                  dv r?t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  d	d	
      }| j                  dk(  rt        d      t        d      f}nt        d      t        d      f}| j                  dk(  rd}nd}t        |t        j                  |d   |d         | _        t        |t        j                  |d   |d         | _	        | j                  j!                  | j"                  d   j%                  |d         dk\         | j                  j!                  | j"                  d   j%                  |d         dk\         |j'                  | j                  dt        j(                  d       |j'                  | j                  dt        j(                  d       |j'                  |dt        j*                  t        j,                  z  d	       |j'                  |dt        j,                  t        j*                  z  d	       t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  d	d	
      | _        t1        |t        j                  d      | _        | j4                  s*t1        |t        j                  t        d            | _        t1        |t        j                  t        d            }	t7        |t        j                  | j8                  D 
cg c]  }
t;        |
       c}
| j<                        | _        | j>                  jA                  | jB                         | j4                  r0| jD                  j8                  tG        | jB                           d   }nd}tI        |t        j                  d |z  t        jJ                  !      | _&        tO        |t        j                  d"      | _(        | j4                  rI| jD                  jS                  | jD                  j8                  tG        | jB                           d         }ng }t7        |t        j                  |#      | _*        tI        |t        j                  d$      | _+        tO        |t        j                  d"      | _,        | jX                  j[                  t        d%             d&| j"                  v rC| jV                  j!                  d'       | jX                  j!                  | j"                  d&          d(| j"                  v r| jL                  j!                  d'       | j"                  d(   j]                         j_                  d)d      }| jT                  jA                  |d          | jP                  j!                  |d          d}| j4                  s:| j.                  j'                  | j2                  dd*t        j(                  d+       d}| j.                  j'                  |	d|z   dft        j(                  d       | j.                  j'                  | j>                  d|z   dft        j(                  t        j*                  z  d       | j.                  j'                  | jL                  d|z   dft        j(                  d       | j.                  j'                  | jT                  d|z   dft        j(                  d       | j.                  j'                  | jP                  d|z   d,ft        j(                  d       | j.                  j'                  | jV                  d,|z   dft        j(                  d       | j.                  j'                  | jX                  d,|z   dfd-t        j(                  t        j*                  z  d+       |j'                  | j.                  dt        j*                  t        j,                  z  d	       |j'                  |dt        j,                  t        j*                  z  d	       t        |t        j                  dt        d.      z        }t        j                  |t        j                        }t        |t        j                  t        d/            | _0        | j"                  d0   d1k(  r| j`                  j!                  d'       n| j`                  j!                  d2       |j'                  | j`                  dt        j*                  t        j,                  z  d	       |j'                  |dt        j,                  t        j*                  z  d	       | jc                  t        jd                  | jf                  | j>                         |ji                  |       |jk                          |S c c}
w )3Nr   r   r   r   r   r   zData selectionr  r`  ra  r  zFeature typer   rn   r   ra  r  r`  r  )pointcentroid)r  boundaryr   r   r   re  ro   r  r   r   r   r  zLayer selectionr   r   z.Database connection is not defined in DB file.zSelect layer:r  tablezSELECT * FROM %s WHEREr   r  r   zChoose categories z!list of categories (e.g. 1,3,5-7)catsTr    r   r   rp   r   MaskzUse current maskmaskedr~   F)6r!   rD   r   r  r  r   r]  r  
checkType1
checkType2r  r&   r  r  r  r   r   r  findr  r  r  r  gridBagSizerLr'   warningr  r   r  r   r   layerChoicer   r  r  r}   r"   r  
radioWherer(   textCtrlWhere
GetColumnschoiceColumns	radioCatstextCtrlCatsrY  r  r  maskrC   r  OnLayerr^  r`  )rG   r  r  r   rA  r  r  r   re  r  rQ  r0  r  r   rows                  rH   r  z%VPropertiesDialog._DataSelectionPanel  s   		@P@P
 	e!,<*=>R[[) -10$/99++&1^;L2LC %%c2==9E??:LyyH$8an57Q|_5yyH$,+&"))58$q'DO '"))58$q'DO OO$$T%9%9&%A%F%FtAw%OST%TUOO$$T%9%9&%A%F%FtAw%OST%TUV"2J2JST   V"2J2JST   IIlqryy2667IRSITJJu"))1CAJN u&1EVCW:WX!!#r}}5__!!<!%BIIR@%99HIDL
 %BIIQ5GH!yy+/;;74SY7""	
 	++DNN;??NN))#dnn*=>wGEE%yy*U2++	
 &e		D??>>,,%%c$..&9:7CD D#EbiiF$Uryy@TU$UryyC$$Q'J%KLT)))NN##D)&&t';';F'CDd***OO$$T*((1779??QGE11%(;''a1""-- #  Cq3wl)A)A! 	 	
 	S!))BII5	 	 	
 	OO!c'1B4L4LUV 	 	
 	S!))	 	 	
 	S!))	 	 	
 	NNS!23K3KTU 	 	
 	S!))BII5 	 	
 			$$$RVV9KTU	V

5QRVVbii-?
J u&1V9:LM!!#r}}5Uryy:L8MN	)S0IIt$IIu%		$))		BFF0B1	M

5QRVVbii-?
J		"--t/?/?@v		U 8s   i0c           	         t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd	
      | _        t        |t        j                  t        d            | _        | j                  j                  | j                   d   dk7         t#        |t        j                  t        d            }t%        |t        j                  ddddt&        j(                        | _        | j*                  j-                  d       | j*                  j/                  d	       | j                   d   d| j                   d<   | j                   d   dk7  r)| j*                  j                  | j                   d          n| j*                  j                  d       t#        |t        j                  t        d            }t1        |t        j                        | _        | j                   d   dk7  r2| j2                  j5                  t7        | j                   d                n$| j2                  j5                  t7        d             | j                  j9                  | j                  ddt        j:                  d       | j                  j9                  |dt        j:                  d       | j                  j9                  | j*                  dt        j:                  t        j<                  z  d       | j                  j9                  |dt        j:                  d       | j                  j9                  | j2                  d t        j:                  d       |j9                  | j                  dt        j<                  t        j>                  z  d!       |j9                  |dt        j>                  t        j<                  z  d!       | jA                  t        jB                  | jD                  | j                         t        |t        j                  dt        d"      z        }t        j                  |t        j                        }t        j                  dd	
      | _#        t        |t        j                  t        d#            | _$        | jH                  j                  | j                   d$   dk7  xs | j                   d%   d u       tK        |t        j                  t        d&      t        jL                  '      | _'        | jP                  r*| jN                  j                  | j                   d%           n| jN                  j                  d(       t1        |t        j                        | _)        | j                   d$   dk7  r2| jR                  j5                  t7        | j                   d$                n$| jR                  j5                  t7        d)             tK        |t        j                  t        d*            | _*        | jW                  |+      | _,        | jP                  r| j                   d%   rD| jT                  j                  d,       | jX                  j[                  | j                   d%          n6| jT                  j                  d(       | jX                  j]                  d       | jX                  j_                  | jP                         | jT                  j_                  | jP                         | jF                  j9                  | jH                  ddt        j:                  d       | jF                  j9                  | jN                  dt        j:                  d       | jF                  j9                  | jR                  dt        j:                  d       | jF                  j9                  | jT                  dt        j:                  d       | jF                  j9                  | jX                  d t        j:                  t        j<                  z  d       |j9                  | jF                  dt        j<                  t        j>                  z  d!       |j9                  |dt        j>                  t        j<                  z  d!       | jA                  t        jB                  | j`                  | jH                         | jA                  t        jb                  | jd                  | jT                         | jA                  t        jb                  | jd                  | jN                         |jg                  |       |ji                          |S )-Nr)  r*  Colorsr  r  Outliner   rn   rp   r   draw outliner   r<  noneWidth (pts):r   r         ?ro   r   min_valmax_val	incrementr   r   %fr   Color:r:  r.   r   r   r   r   r   r   r#  r  Fillz
fill colorfcolor	rgbcolumnchoose color:r   Fr9   color from map table column:r  T)5r!   rD   r   r  r  r   r]  r  r&   r  r  r  gridBagSizerOr   outlineCheckr   r  r'   r   fsFS_RIGHT	widthSpin	SetFormat	SetDigitsr   colorPickerr=  r>  r  r  r  r  rC   r@  r  gridBagSizerF	fillCheckr"   r  colorPickerRadior  fillColorPickercolorColRadiogetColsChoicecolorColChoicer   r  r  r  r?  r  r^  r`  )rG   r  r  r   rA  r  	widthText	colorTexts           rH   r  z'VPropertiesDialog._ColorsPointAreaPanelL	  sk   		@P@P
 	e!H+6R[[) u&1Y<:OP!!#r}}5__!!<$Uryy.@QR""4#7#7#@F#JKu!N:KL	"yy++
 	  &  #(0,2D  )(F2NN##D$8$8$ABNN##A&u!H+F	+Ebii@(F2&&z$2F2Fw2O'PQ&&z'':;)) 	 	
 	6(@(@ 	 	
 	NN))BII5	 	 	
 	6(@(@ 	 	
 	&r/G/GPQ 	 	
 			$$$RVV9KTU	V

5QRVVbii-?
J		"//4>>43D3DE u&1V9:LM!!#r}}5__!!<!%BIIQ|_M  *f4 =##K0<	

 !,biiq'9!
 ??!!**t/C/CK/P+PQ!!**51/"))D)V3  **:d6J6J86T+UV  **:e+<=(biiq)G'H
 #000>??##K0""++D1##66((5 ""++E2##003""4??3!!$//2NN)) 	 	
 	!!vB4L4LUV 	 	
 	  f23K3KTU 	 	
 	F1I1IRS 	 	
 	))BII5	 	 	
 			$$$RVV9KTU	V

5QRVVbii-?
J		"//4;;?		"$$dllD4F4FG		"$$dllD4I4IJv		rI   c           	      T   t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd	
      | _        | j                  d   d| j                  d<   | j                  d   d| j                  d<   t        |t        j                  t        d            | _        | j                  j!                  | j                  d   dk7         | j                  j#                  t        d             t%        |t        j                  t        d            }t'        |t        j                  ddddt(        j*                        | _        | j,                  j/                  d       | j,                  j1                  d       | j                  d   dk7  r)| j,                  j!                  | j                  d          n| j,                  j!                  d       t%        |t        j                  t        d            }t3        |t        j                        | _        | j                  d   dk7  r2| j4                  j7                  t9        | j                  d                n$| j4                  j7                  t9        d             | j                  j;                  | j                  ddt        j<                  d       | j                  j;                  |dt        j<                  d        | j                  j;                  | j,                  dt        j<                  t        j>                  z  d        | j                  j;                  |d!t        j<                  d        | j                  j;                  | j4                  d"t        j<                  d        |j;                  | j                  dt        j>                  t        j@                  z  d#       |j;                  |dt        j@                  t        j>                  z  d#       | jC                  t        jD                  | jF                  | j                         t        |t        j                  dt        d$      z        }t        j                  |t        j                        }t        j                  dd	
      | _$        t%        |t        j                  t        d%            }tK        |t        j                  t        d&      t        jL                  '      | _'        | jP                  r*| jN                  j!                  | j                  d(           n| jN                  j!                  d)       t3        |t        j                        | _)        | j                  d   dk7  r2| jR                  j7                  t9        | j                  d                n$| jR                  j7                  t9        d             tK        |t        j                  t        d*            | _*        | jW                  |+      | _,        | jP                  r| j                  d(   rD| jT                  j!                  d,       | jX                  j[                  | j                  d(          n6| jT                  j!                  d)       | jX                  j]                  d       | jX                  j_                  | jP                         | jT                  j_                  | jP                         | jH                  j;                  |ddt        j<                  d       | jH                  j;                  | jN                  dt        j<                  d        | jH                  j;                  | jR                  dt        j<                  d        | jH                  j;                  | jT                  d!t        j<                  d        | jH                  j;                  | jX                  d"t        j<                  t        j>                  z  d        |j;                  | jH                  dt        j>                  t        j@                  z  d#       |j;                  |dt        j@                  t        j>                  z  d#       | jC                  t        j`                  | jb                  | jT                         | jC                  t        j`                  | jb                  | jN                         |je                  |       |jg                          |S )-Nr)  r*  rE  r  r  rF  r   rn   rp   r   hcolorrH  r<  rG  r   z*No effect for fill color from table columnrI  r   r   rJ  ro   rK  rO  hwidthrP  r:  r.   r   r   r   r   r   r   r#  r  rQ  zColor of lines:rT  r   rS  FrU  r  T)4r!   rD   r   r  r  r   r]  r  r&   r  r  r  rV  r  r   rW  r   rY  r'   r   rX  rY  outWidthSpinr[  r\  r   r]  r=  r>  r  r  r  r  rC   r@  r  r^  r"   r  r`  r  ra  rb  rc  rd  r   r  r  r?  r  r^  r`  )	rG   r  r  r   rA  r  re  rf  fillTexts	            rH   r  z"VPropertiesDialog._ColorsLinePanel	  sO   		@P@P
 	e!H+6R[[) u&1Y<:OP!!#r}}5__!!<)1-3D  *(0,2D  )$Uryy.@QR""4#7#7#AV#KL$$Q'S%TUu!N:KL	%yy++
 	##D)##A&)V3&&t';';H'EF&&q)u!H+F	+Ebii@)V3&&z$2F2Fx2P'QR&&z'':;)) 	 	
 	6(@(@ 	 	
 	))BII5	 	 	
 	6(@(@ 	 	
 	&r/G/GPQ 	 	
 			$$$RVV9KTU	V

5QRVVbii-?
J		"//4>>43D3DE u&1V9:LM!!#r}}5__!!<e		;L9MN +biiq'9!

 ??!!**t/C/CK/P+PQ!!**51/"))D(F2  **:d6J6J76S+TU  **:g+>?(biiq)G'H
 #000>??##K0""++D1##66((5 ""++E2##003""4??3!!$//2&vB4L4LUV 	 	
 	!!vB4L4LUV 	 	
 	  f23K3KTU 	 	
 	F1I1IRS 	 	
 	))BII5	 	 	
 			$$$RVV9KTU	V

5QRVVbii-?
J		"$$dllD4F4FG		"$$dllD4I4IJv		rI   c                     t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd	      }t        |t        j                  t        d
      t        j                        | _        | j                  j                  t!        | j"                  d                t%        |t        j                        | _        | j&                  j)                  | j"                  d          t        j*                  t,        j.                  j1                  t2        j4                  | j"                  d         dz         }t7        |t        j                  |      | _        t        |t        j                  t        d            | _        | j:                  j                  t!        | j"                  d                t=        |t        j                  dt        d      t        d      t        d      dddt        j>                  
      | _         | j"                  d   s| j@                  j                  d       n(| j@                  j                  | j"                  d          |jC                  | j                  dt        jD                  d       |jC                  | j&                  dt        jD                  t        jF                  z  d       |jC                  | j8                  dt        jH                  d       |jC                  | j:                  dt        jD                  d       |jC                  | j@                  d d!t        jD                  t        jJ                  z  d"       |jM                  d#       |jM                  d$       |jC                  |d#t        jJ                  t        jN                  z  d%       |jC                  |dt        jN                  t        jJ                  z  d%       | jQ                  t        jR                  | jT                  | j8                         | jQ                  t        jV                  | jX                  | j                         | jQ                  t        jV                  | jX                  | j:                         t        |t        j                  dt        d&      z        }t        j                  |t        j                        }t        j                  dd	      }t        |t        j                  t        d'      t        j                        | _-        t]        |t        j                  d#d(d#)      | _/        t        |t        j                  t        d*            | _0        | jc                  |      | _2        t%        |t        j                  t        d+            | _3        t]        |t        j                  d#d,d#)      | _4        | jZ                  j                  | j"                  d-   d u       | j`                  j                  t!        | j"                  d.                | j"                  d-   r)| j^                  j                  | j"                  d-          n| j^                  j                  d       | j"                  d.   rQ| jh                  j                  | j"                  d/          | jd                  jk                  | j"                  d.          n6| jh                  j                  d#       | jd                  jm                  d       | jn                  sC| j`                  | jd                  | jh                  | jf                  fD ]  }|jq                           |jC                  | jZ                  dt        jD                  d       |jC                  | j^                  dt        jD                  d       |jC                  | j`                  dt        jD                  d       |jC                  | jd                  d t        jD                  t        jJ                  z  d       |jC                  | jf                  d0t        jD                  t        jH                  z  d       |jC                  | jh                  d1t        jD                  d       |jM                  d       |jC                  |d#t        jJ                  t        jN                  z  d%       |jC                  |dt        jN                  t        jJ                  z  d%       | jQ                  t        jV                  | jr                  | jZ                         | jQ                  t        jV                  | jr                  | j`                         t        |t        j                  dt        d2      z        }t        j                  |t        j                        }t        j                  dd	      }tu        |t        j                  t        d3            | _;        t        |t        j                  t        d4      t        j                        | _<        t]        |t        j                  dd5d)      | _=        t        |t        j                  t        d6            | _>        | jc                  |      | _?        | jv                  j                  | j"                  d7          | jx                  j                  | j"                  d8   d u       | j|                  j                  t!        | j"                  d9                | j"                  d8   r)| jz                  j                  | j"                  d8          n| jz                  j                  d       | j"                  d9   r)| j~                  jk                  | j"                  d9          n| j~                  jm                  d       |jC                  | jv                  dd!t        jD                  d"       |jC                  | jx                  d t        jD                  d       |jC                  | jz                  d!t        jD                  d       |jC                  | j|                  d1t        jD                  d       |jC                  | j~                  d:t        jD                  t        jJ                  z  d       |jM                  d#       |jC                  |d#t        jJ                  t        jN                  z  d%       |jC                  |dt        jN                  t        jJ                  z  d%       | jQ                  t        j                  | j                  | jv                         | jQ                  t        jV                  | j                  | jx                         | jQ                  t        jV                  | j                  | j|                         |j                  |       |j                          |S );Nr)  r*  Size and styler  r  	Symbologyr   rn   r   zsymbol:r   r   r:  .pngr   bitmapz	eps file:r   epsr   Browse,Type filename or click browse to choose fileChoose a file9Encapsulated PostScript (*.eps)|*.eps|All files (*.*)|*.*	r   	labelText
buttonTexttoolTipdialogTitlestartDirectoryinitialValuefileMaskfileModer   r   r   r   r2  r  r   r   r   r   ro   rp   r  Sizezsize:r1  r3  zsize from map table column:zscale:   r   
sizecolumnr   r   r   Rotationzrotate symbols:zcounterclockwise in degrees:h  zfrom map table column:rotationrotaterotatecolumnr#  )Er!   rD   r   r  r  r   r]  r  r&   r  r  r  r"   r  symbolRadior   rt  r  r'   
symbolNamer  Bitmapr  r  ru  r   SYMBDIRr   symbolButtonepsRadior   FD_OPENepsFileCtrlr  r  r  r  r  r  r  rC   rX  OnSymbolSelectionr?  r"  	sizeRadior%   sizeSpinsizecolumnRadiorc  sizeColChoicerG  	scaleSpinr   r  r  r  r   r   rotateCheckrotateRadio
rotateSpinrotatecolumnRadiorotateColChoicer@  r!  OnRotationTyper^  r`  )	rG   r  r  r   rA  r  r  rq  rQ  s	            rH   r  z"VPropertiesDialog._StylePointPanelo
  s
   		@P@P
 	e!,<*=>R[[) u&1[>:QR!!#r}}5AA6&biiq|2;;
 	!!$t';';H'E"FG$Uryy9  !5!5h!?@GGLL**D,@,@,JKfT
 )299VL#Ebiiq~NtD$8$8$?@A+yy{DE/*PZZ
 ##E*%%b)%%d&:&:5&AB&r/G/GPQ 	 	
 	OO))BGG3	 	 	
 	**R^^TUVMMvB,D,DQ 	 	
 	))BII5 	 	
 	##A&##A&		,1299rvv3Ea	P

5QRVVbii-?
J		"--!7!79J9JK		"$$d&6&68H8HI		"$$d&6&6F u&1V9:LM!!#r}}5AA6$biiqz
 !299!QO*biiq)F'G 
 "//6#Ebiiq{K!%BII1"aP 4 4V <D HI%%d4+?+?+M&NO'MM""4#7#7#?@MM""1%-NN##D$8$8$AB11$2F2F|2TUNN##A&++A.$$""	   	NNR-E-Ea 	 	
 	MMvB,D,DQ 	 	
 	  f23K3KTU 	 	
 	))BII5	 	 	
 	NN))BNN:	 	 	
 	NNR-E-Ea 	 	
 	##A&		,1299rvv3Ea	P

5QRVVbii-?
J		"$$dkk4>>B		"$$dkk43G3GH u&1Z=:PQ!!#r}}5AA6#EbiiqAR?ST&yy23++	
 #5RYYA3PQR!,biiq)A'B"
  $11%8!!$"6"6z"BC!!$"6"6x"@"LM''T-A-A.-Q(RS)OO$$T%9%9(%CDOO$$Q'/  33$$^4   --a0)) 	 	
 	&r/G/GPQ 	 	
 	OOb.F.Fq 	 	
 	""R5M5MVW 	 	
 	  ))BII5	 	 	
 	##A&		,1299rvv3Ea	P

5QRVVbii-?
J		"//4??D4D4DE		"$$d&9&94;K;KL		"$$d&9&94;Q;QRv		rI   c           	      
   t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd	      }t        |t        j                  t        d
            }t        |t        j                  ddddt        j                        | _        | j                   j#                  d       | j                   j%                  d       t'        |t        j                  t        d            | _        | j*                  d   rD| j                   j-                  | j*                  d          | j(                  j-                  d       nC| j                   j-                  | j*                  d          | j(                  j-                  d       |j/                  |dt        j0                  d       |j/                  | j                   dt        j0                  d       |j/                  | j(                  ddt        j0                  d       |j/                  |dt        j2                  t        j4                  z  d       |j/                  |dt        j4                  t        j2                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd	      }t        |t        j                  t        d            }g d }	t7        ||	!      | _        t        |t        j                  t        d"            }
t;        |t        j                  g d#$      | _        | j8                  j-                  | j*                  d%          | j<                  j?                  | j*                  d&          |j/                  |dt        j0                  d       |j/                  | j8                  dt        j0                  t        j2                  z  d       |j/                  |
dt        j0                  d       |j/                  | j<                  d't        j0                  t        j2                  z  d       |j/                  |dt        j2                  t        j4                  z  d       |j/                  |dt        j4                  t        j2                  z  d       |jA                  |       |jC                          |S )(Nr)  r*  rm  r  r  ro  r   rn   r   zSet width (pts):r   r   r   rJ  ro   rK  rO  z multiply width by category valuer   FcwidthTr   r   r   r   r   r   r  
Line stylezChoose line style:)soliddasheddotted
dashdotted)r   zChoose linecap:)buttroundextended_buttr   r   linecapr   )"r!   rD   r   r  r  r   r]  r  r&   r  r  r  r'   r   rX  rY  rZ  r[  r\  r   cwidthCheckr  r   r  r  r  r  rk   
styleCombor   linecapChoicer   r^  r`  )rG   r  r  r   rA  r  r  re  	styleText	penStyleslinecapTexts              rH   r  z!VPropertiesDialog._StyleLinePanelC  s%   		@P@P
 	e!,<*=>R[[) u&1W::MN!!#r}}5AA6u!<N:OP	"yy++
 	  &  ##biiq)K'L
 (NN##D$8$8$AB%%e,NN##D$8$8$BC%%d+R5M5MVWXNNR-E-Ea 	 	
 	)) 	 	
 			,1299rvv3Ea	P

5QRVVbii-?
J u&1\?:RS!!#r}}5AA6u!<P:QR	?	*5)D !299A>O<PQ#bii)K
 	  !5!5g!>?--d.B.B9.MNR5M5MVWXOO))BII5	 	 	
 	V"*B*B1 	 	
 	))BII5	 	 	
 			,1299rvv3Ea	P

5QRVVbii-?
Jv		rI   c                 T	   t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd	      }t        |t        j                  t        d
            | _        t        |t        j                  t        d      t        d      t        d      t        d      | j                  ddt        j                   
      | _        t%        |t        j                  t        d            | _        t)        |t        j                  ddd      | _        t%        |t        j                  t        d            | _        t)        |t        j                  ddd      | _        | j                  j1                  t3        | j4                  d                | j                  j7                         rx| j"                  j1                  | j4                  d          | j*                  j1                  | j4                  d          | j.                  j1                  | j4                  d          |j9                  | j                  dt        j:                  d       |j9                  | j"                  ddt        j:                  t        j<                  z  d        |j9                  | j&                  d!t        j:                  d       |j9                  | j*                  d"t        j:                  d       |j9                  | j,                  d#t        j:                  d       |j9                  | j.                  d$t        j:                  d       |j?                  d       |j9                  |dt        j<                  t        j@                  z  d%       |j9                  |dt        j@                  t        j<                  z  d%       | jC                  t        jD                  | jF                  | j                         |jI                  |       |jK                          |S )&Nr)  r*  rm  r  r  Patternr   rn   r   zuse pattern:r   zChoose pattern file:rs  rt  ru  r   rv  rw  zpattern line width (pts):ro   r  r3  zpattern scale factor:patpwidthr   r   r   r   r   r   r   r   r   r   r  r  )&r!   rD   r   r  r  r   r]  r  r&   r  r  r  r   patternCheckr   r  r  patFileCtrlr'   patWidthTextr%   patWidthSpinpatScaleTextpatScaleSpinr   rt  r  rP   r  r  r  r  r  rC   r@  r#  r^  r`  rG   r  r  r   rA  r  r  s          rH   r  z!VPropertiesDialog._StyleAreaPanel  s   		@P@P
 	e!,<*=>R[[) u&1Y<:OP!!#r}}5AA6$Uryy.@QR+yy./{DE/*++PZZ
 'biiq)D'E
 %UryyaRQRS&biiq)@'A
 %UryyaRQRS""4(<(<U(C#DE%%'%%d&:&:5&AB&&t';';H'EF&&t';';G'DE60H0HQR 	 	
 	))BII5 	 	
 	60H0HQR 	 	
 	60H0HQR 	 	
 	60H0HQR 	 	
 	60H0HQR 	 	
 	##A&		,1299rvv3Ea	P

5QRVVbii-?
J		"//4>>43D3DEv		rI   c                 6   | j                   j                         | j                  k(  ry| j                   j                         | _        | j                  rI| j                  j                  | j                  j                  t        | j                           d         }ng }| j                  j                  |       | j                  j                  d       | j                  dv r7| j                  j                  |       | j                  j                  d       yy)zChange columns on layer changeNr0  r   )ra  r`  )r:  r  r  r  r  r=  r  r}   r>  r;  r  r  rd  )rG   rc   r  s      rH   rB  zVPropertiesDialog.OnLayer  s    ..0DNNB))<<>??>>,,%%c$..&9:7CD D##D)''*99++((.,,Q/ ,rI   c                     | j                   j                         D ]W  }|j                         | j                  k7  s!|j                         j	                  | j                  j                                Y y r@   )rV  r>  rO   rW  r  rP   rG   rc   widgets      rH   r  zVPropertiesDialog.OnOutline  s_    ((446 	HF!T%6%66  "))$*;*;*D*D*FG	HrI   c                    | j                   j                         }| j                  j                  |       | j                  j                  |       | j
                  j                  |       | j                  j                  |       |r| j                  d        | j                  s5| j                  j                          | j                  j                          y y r@   )
r_  rP   rd  r  rb  ra  r`  r  r  r  )rG   rc   r  s      rH   r  zVPropertiesDialog.OnFill	  s    ((*""6*!!&)##F+$$V,LL'')&&( rI   c                     | j                   j                  | j                  j                                | j                  j                  | j
                  j                                y r@   )rd  r  rb  rP   ra  r`  rK  s     rH   r  zVPropertiesDialog.OnColor  sH    ""4#5#5#>#>#@A##D$9$9$B$B$DErI   c                    | j                   j                  | j                  j                                | j                  j                  | j
                  j                                | j                  j                  | j
                  j                                | j                  j                  | j
                  j                                y r@   )r  r  r  rP   r  r  rG  r  rK  s     rH   r   zVPropertiesDialog.OnSize  s    T^^4467!!$"6"6"?"?"ABd22;;=>d22;;=>rI   c                    | j                   | j                  | j                  | j                  fD ]O  }| j                  j                         r#|j                          | j                  d        @|j                          Q y )N)rc   )	r  r  r  r  r  rP   r  r  r  rP  s      rH   r!  zVPropertiesDialog.OnRotation   sl    ""  OO	
 
	D ((*##$#/
	rI   c                     | j                   j                  | j                  j                                | j                  j                  | j
                  j                                y r@   )r  r  r  rP   r  r  rK  s     rH   r  z VPropertiesDialog.OnRotationType-  sF    t//88:;##D$:$:$C$C$EFrI   c                     | j                   | j                  | j                  | j                  | j                  fD ]+  }|j                  | j                  j                                - y r@   )r  r  r  r  r  r  r  rP   rP  s      rH   r#  zVPropertiesDialog.OnPattern1  s]    
 	6D KK))2245	6rI   c                     | j                   j                         }| j                  j                  |       | j                  j                  |       | j
                  j                  |        y r@   )r  rP   r  r  r  r  )rG   rc   	useSymbols      rH   r"  zVPropertiesDialog.OnSymbology;  sR    $$--/	  +y)I.rI   c                    t        | t        j                  | j                  j	                               }|j                         t        j                  k(  rl|j                         }|j                         }| j                  j                  t        j                  |dz                | j                  j                  |       |j                          y N)r  currentSymbolro  )r   r   r  r  GetLabelr  rD   rU  GetSelectedSymbolPathGetSelectedSymbolNamer  SetBitmapLabelr  r  rO  rG   rc   r  imgre  s        rH   r  z#VPropertiesDialog.OnSymbolSelectionB  s    Y..doo>V>V>X
 ==?bhh&++-C,,.D,,RYYsV|-DEOO$$T*rI   c                     | j                   j                         D ]?  }|j                         | j                  k7  s!|j                         j	                  |       A y r@   )r8  r>  rO   r9  r  )rG   r  r  s      rH   r  z&VPropertiesDialog.EnableLayerSelectionN  sL    ((446 	2F!T\\1  "))&1	2rI   c                     | j                   rI| j                  j                  | j                  j                  t	        | j
                           d         }ng }t        |t        j                  |      }|S )z#Returns a Choice with table columnsr0  )r   r   r   )	r  r  r=  r  r}   r  r   rD   r   )rG   r   r  r  s       rH   rc  zVPropertiesDialog.getColsChoiceS  s[    ??>>,,%%c$..&9:7CD Dv"))TBrI   c                 B   | j                   dv rd }| j                  j                         rU| j                  j                         }| j                  j                         rU|d| j                  j                         z   z  }n4| j                  j                         r| j                  j                         }|r|| j
                  d<   | j                  | j
                  d<   | j                  r| j                  j                         | j
                  d<   | j                  j                         rB| j                  j                         s(| j                  j                         | j
                  d<   ny| j                  j                         r_| j                  j                         sE| j                  j                         dz   | j                  j                         z   | j
                  d<   | j                  j                         rd	| j
                  d
<   nd| j
                  d
<   | j                   dv rT| j                   j                         rXt#        | j$                  j'                               | j
                  d<   | j(                  j                         | j
                  d<   nd| j
                  d<   | j*                  j                         r| j,                  j                         r?t#        | j.                  j'                               | j
                  d<   d | j
                  d<   | j0                  j                         rFd| j
                  d<   | j2                  j                         | j
                  d<   nd| j
                  d<   | j                   dk(  r*| j                   j                         rXt#        | j$                  j'                               | j
                  d<   | j4                  j                         | j
                  d<   nd| j
                  d<   | j,                  j                         r?t#        | j.                  j'                               | j
                  d<   d | j
                  d<   | j0                  j                         r6d| j
                  d<   | j2                  j                         | j
                  d<   | j                   dk(  r| j6                  j                         r7| j8                  j;                         | j
                  d<   d | j
                  d<   n'| j<                  j                         | j
                  d<   | j>                  j                         rF| j@                  j                         | j
                  d<   d | j
                  d<   d | j
                  d<   n]| jB                  j                         | j
                  d<   | jD                  j                         | j
                  d<   d | j
                  d<   d | j
                  d<   d | j
                  d<   d| j
                  d<   | jF                  j                         rd| j
                  d<   | jH                  j                         r(| jJ                  j                         | j
                  d<   n'| jL                  j                         | j
                  d<   | j                   d k(  rd | j
                  d!<   | jN                  j                         rtQ        | jR                  j                               ru| jR                  j                         | j
                  d!<   | jT                  j                         | j
                  d"<   | jV                  j                         | j
                  d<   | j                   dk(  r | jX                  j                         r7| j(                  j                         | j
                  d#<   d | j
                  d<   n6| j(                  j                         | j
                  d<   d | j
                  d#<   | jZ                  j                         r(| jZ                  j                         | j
                  d$<   nd%| j
                  d$<   | j\                  j                         | j
                  d&<   y y )'Nr+  z or r  r  r  r1  r2  r   r~   r4  rh  r  r<  r   rH  rR  rS  r`  rh  ri  ra  r   rr  r   r  r   r  r  Fr  Tr_  r  r  r  r   r  r  )/r  r5  rP   GetNamer6  r  r  r:  r  r?  r@  r  r;  r<  r>  rA  rW  r>  r]  r~  rZ  r_  r`  ra  rb  rd  rj  r  r  r  r  r  r  r  r  r  r  r  r  r  rt  r  r  r  r  r  r  )rG   featureTypes     rH   rB  zVPropertiesDialog.update_  s   99++K'')"oo557??++-6DOO,C,C,E#EEK))+"oo557/:$$V, .2__\*??,0,<,<,O,O,QD  )~~&&(1B1B1J1J1L/3/@/@/I/I/K$$V,))+D4F4F4N4N4P&&99;((1134 $$W- 99-0D  *-0D  * 99++  ))+0:4;K;K;U;U;W0X$$W-040G0G0I$$W-06$$W-~~&&(((1135?,,6686D((2 9=D((5%%..05;D((2 ++>>@ ((# 28$$X.99   ))+1;$$..02$$X. 261B1B1K1K1M$$X. 28$$X.$$--/0:((2241$$W- 59$$[1!!**,06$$W- ''::< $$ 99 ((*151I1I1K$$X..2$$U+.2.>.>.G.G.I$$U+~~&&(/3}}/E/E/G$$V,59$$\204$$W- &&99; $$  150G0G0I$$W-/3$$V, .2D  *37D  0/4D  ,((*37$$Z0((*151I1I1K$$X. ((;;= $$" 99*.D  '  ))+T5E5E5N5N5P0Q.2.>.>.G.G.I$$U+151B1B1K1K1M$$X.040A0A0J0J0L$$W-99((*151H1H1J$$X.04$$W-040G0G0I$$W-15$$X.'')040H0H0J$$W-07$$W-.2.@.@.S.S.UD  +  rI   Nrg  )re   rf   rg   rA   rf  r  r  r  r  r  r  rB  r  r  r  r   r!  r  r#  r"  r  r  rc  rB  ri   rI   rH   r  r  O  s~    @D(dLRhM^RhbHHT0&H
)F?G6/
2

GVrI   r  c                   ~    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d Zd Zd Zd Zd Zd Zd Zy)LegendDialogc                    t         j                  | ||d||       d| _        || _        | j                  j	                  d      }|r|j
                  | _        nd | _        | j                  j	                  d      }|r|j
                  | _        nd | _        | j                  j	                  d      }|r|j
                  | _        nd | _        | j                  j	                  d      j
                  | _	        | j                  | j                     j                         }	| j
                  d   A| j                  | j
                  d      | _        | j                  j                         | _        nvt               | j
                  d<   t        | j
                  d   | j                  	      | _        | j                  j                         | _        |	d
   |	d   f| j                  d<   | j
                  d   0| j                  | j
                  d      j                         | _        ngt               | j
                  d<   t#        | j
                  d   | j                  	      }
|
j                         | _        |	d
   |	d   f| j                   d<   | j                  r"| j                  | j                     d   | _        nd | _        t'        | t(        j*                  t(        j,                        | _        | j1                  | j.                        | _        | j5                  | j.                        | _        | j9                  d        | j;                  d        | j=                  d        | j?                  d        | jA                  d        | jC                  | j.                         | j.                  jE                  |       | j.                  jG                  t(        jH                  | jJ                         y )NzLegend settingsrk  )rasterLegendr  r  r  r  r  r   r  rq  rs  r   ro   r  )&r   rA   r   r   rp  r   r  vectorIdr  pageIdr  r  rLegendDictr  RasterLegendr   vLegendDictVectorLegend
currRasterr   rD   r   r  r  _rasterLegendpanelRaster_vectorLegendpanelVectorr  OnRange
OnIsLegendOnSpanr  rf  ChangeSelectionrC   EVT_NOTEBOOK_PAGE_CHANGINGOnPageChanging)rG   r   r   r   r  r   r  r  r  currPager  s              rH   rA   zLegendDialog.__init__  s   # 	 	
 ;#44U;DJDJ!!77A"IIDM DM!!77A"IIDM DM&&<<VDGG##DKK0??A771:! $ 0 0 <D#00??ADDGGAJ ,TWWQZTXX FD#00??AD(0(8(5/(IDW% 771:!#//
;JJLDDGGAJ'
AL+::<D(0(8(5/(IDW%=="..t}}=hGDO"DO !"--P--dmm<--dmm<dTDdT]]#%%d+288$:M:MNrI   c                     t        j                  | j                  d      j                  | j                  d             t        j                  | j                  d      j                  | j                  d             y)z+Workaround to scroll up to see the checkboxrasterPanelshowRLegendvectorPanelshowVLegendN)rD   	CallAfterFindWindowByNameScrollChildIntoViewrK  s     rH   r  zLegendDialog.OnPageChanging/  s`    
!!-0DD!!-0	
 	!!-0DD!!-0	
rI   c           	         t        |t        j                  dt        j                        }|j	                  dd       |j                  d       |j                  |t        d             t        j                  t        j                        }t        |t        j                  t        d	      
      | _        | j                  j                  | j                  d          | j                  j                  d       |j                  | j                  dt        j                  t        j                   z  d       t#        |t        j                  dt        d      z        }t        j$                  |t        j                        }t        j&                  ddd      }t)        |t        j                  t        d      t        j*                        | _        t)        |t        j                  t        d      
      | _        | j,                  j                  | j                  d          | j.                  j                  | j                  d           t1        | j2                        }t5        |t        j                  t        d      | j2                  |dz  
      | _        t9        |t        j                  t:        j<                  dddd       | _        | j                  d   s)| j>                  j                  | j                  d          n| j>                  j                  d       |j                  | j,                  dt        j@                  d       |j                  | j6                  dt        j@                  t        jB                  z  d       |j                  | j.                  dt        j@                  d       |j                  | j>                  dt        j@                  t        jD                  z  d       |jG                  d        |j                  |d t        j                  t        j                   z  d        |j                  |dt        j                  t        j                   z  d       t#        |t        j                  dt        d!      z        }t        j$                  |t        j                        }t        j                  t        j                        }t)        |t        j                  dt        d"      z  t        j*                  #      | _$        t)        |t        j                  dt        d$      z        | _%        |j                  | jH                  d t        j                   t        j                  z  d       |j                  | jJ                  d t        j                   t        j                  z  d       |j                  |d t        j                  t        j                   z  d        |j                  |dt        j                  t        j                   z  d       | jM                  d||%       t#        |t        j                  dt        d&      z        }t        j$                  |t        j                        }t        jN                  dd'      }	t        |t        j                  t        d(      
      | _(        | j                  d)   d*k(  r| jP                  j                  d       n| jP                  j                  d       t        |t        j                  t        d+      
      | _)        | j                  d,   d*k(  r| jR                  j                  d       n| jR                  j                  d       | jT                  ra| jV                  | jT                     d   rEtY        jZ                  | jV                  | jT                     d         }
|
d-   |
d.   c| _.        | _/        nd/\  | _.        | _/        t        |t        j                  t        d0      
      | _0        | j`                  j                  | j                  d0          t5        |t        j                  d1| j\                  z  
      | _1        t5        |t        j                  d2| j^                  z  
      | _2        tg        |t        j                  ti        | j                  d-         3      | _5        tg        |t        j                  ti        | j                  d.         3      | _6        |	j                  | jP                  d/d4t        j@                  d5       |	j                  | jR                  d6d4t        j@                  d5       |	j                  | j`                  d7t        j@                  d8       |	j                  | jb                  d9t        j@                  t        jD                  z  d8       |	j                  | jj                  d:t        j@                  d8       |	j                  | jd                  d;t        j@                  t        jD                  z  d8       |	j                  | jl                  d<t        j@                  d8       |j                  |	dd=       |j                  |dt        j                  t        j                   z  d       |jo                  |       |jq                          | js                  t        jt                  | jv                  | j,                         | js                  t        jt                  | jv                  | j.                         | js                  t        jx                  | jz                  | j                         | js                  t        jt                  | j|                  | jH                         | js                  t        jt                  | j|                  | jJ                         | js                  t        jx                  | j~                  | j`                         | j>                  j                         js                  t        j                  | jv                         |S )>Nr   i  r*  FTscroll_xscroll_yr  zRaster legendr  zShow raster legendr   rLegendr  r   rn   r  r  zSource rasterr   rp   r  r   r   zcurrent rasterr   zselect rasterrasterDefaultr  %(rast)s: type %(type)srastr  r  r  r   r2  ro   zType of legendz"discrete legend (categorical maps))r   r   r   r   z5continuous color gradient legend (floating point map)
legendTyper   re  zAdvanced legend settingsr   zdraw "no data" boxnodatar~   zdraw ticks across color tabletickbarr4  r5  r   r  zmin (%s)zmax (%s)r  )ro   rn   r   r   r   r   r   r#  rp   rm   )rp   rq   r  )Br$   rD   r   r  SetupScrollingSetNamer  r   r]  r  r   	isRLegendr   r  r  r  r  r&   r  r,  r"   r  r  rasterOthergetRasterTyper  r'   rasterCurrentr
   r   r+  r  r  r  r  r  discrete
continuoussizePositionFontr  r  ticksr  r   rn  raster_infominimmaximr  minTextmaxTextr(   r   r4  r5  r^  r`  rC   r?  r  r@  r  
OnDiscreter  r  r  )rG   r  r  r   rA  r  rI  
rasterTypevboxr  rinfos              rH   r  zLegendDialog._rasterLegend:  s 	   			AQAQ
 	ed;m$e!O*<=R[[)!%BIIQ?S=TU 0 0 ;<}-

4>>abffryy6HQR
S u&1_CU:UV!!#r{{3$$!!!<	(biiq)9':"++
 'u!OBTU##D$4$4_$EF!!d&6&6&G"GH"t7
'yy-.
;<
 #yy..
 0&&t'7'7'AB&&r*123K3KTU 	 	
 	))BGG3	 	 	
 	1I1IRS 	 	
 	))BNN:	 	 	
 	  #		)0B1	M

5QRVVbii-?
J u&1EUCV:VW!!#r{{3{{2;;'#yy1ABB++	
 &yy1TUU
 	1299rvv3EaPQRYY5GPQR		$1266BII+=a	H

5QRVVbii-?
J 	%6R RYYfq9S7T.T
 !!#r{{3AA6u!<P:QRH%,KK  &KK  'biiq)H'I

 I&#-JJ%JJ&==T--dmm<XF%%d&6&6t}}&Eh&OPE%*5\5<"DJ
%)"DJ
e		7D


D,,W56!%BIIZ$**=TU!%BIIZ$**=TUEbiis4;K;KE;R7STEbiis4;K;KE;R7STKK)) 	 	
 	JJFb6N6NWX 	 	
 	JJF)A)A! 	 	
 	LL))BNN:	 	 	
 	vB4L4LUVWLL))BNN:	 	 	
 	vB4L4LUVW		,1Q	7

5QRVVbii-?
Jv		 			"$$dmmT5G5GH		"$$dmmT5E5EF		"//4??DNNC		"$$doot}}E		"$$dootG		"//4<<<%%',,R[[$--HrI   c                    t        |t        j                  dt        j                        }|j	                  dd       |j                  d       |j                  |t        d             t        j                  t        j                        }t        |t        j                  t        d	      
      | _        | j                  j                  | j                  d          | j                  j                  d       |j                  | j                  dt        j                  t        j                   z  d       t#        |t        j                  dt        d      z        }t        j$                  |t        j                        }t        j&                  dd      }t)        |t        j                  t        d      
      }t+        |      | _        | j,                  j/                  dt        d             | j,                  j/                  dt        d             | j0                  rt3        | j4                  | j0                     d   d       }|D ]  }	| j,                  j7                  | j,                  j9                         |	d   j;                  d      d         }
| j,                  j=                  |
d|	d          | j,                  j?                  |
|
       | j,                  jA                  |
d       |	d   dk(  s| j,                  jA                  |
d        | j0                  s| j,                  jC                  dd       n*| j,                  jC                  dt        jD                         | j,                  jC                  dt        jD                         tG        |t        j                  t        d      
      | _$        tG        |t        j                  t        d       
      | _%        tG        |t        j                  t        d!      
      | _&        |j                  |d"d#t        jN                  d$       |j                  | j,                  d%d&t        jN                  t        j                   z  d$       |j                  | jH                  d't        jN                  d(       |j                  | jJ                  d)t        jN                  d(       |j                  | jL                  d&t        jN                  d(       |jQ                  dd       |jQ                  dd       |j                  |dt        j                   d       |j                  |dt        j                  t        j                   z  d       | jS                  d*||+       t#        |t        j                  dt        d,      z        }t        j$                  |t        j                        }t        jT                  d-dd.      }t        |t        j                  t        d/      
      | _+        tY        |t        j                  t        jZ                  0      | _.        | j                  d1   d2k(  rE| j\                  j_                  t        j`                         | jV                  j                  d       nL| j\                  j_                  tc        | j                  d1                | jV                  j                  d       |j                  | jV                  dt        jN                  d       |j                  | j\                  dt        jN                  d       |j                  |dt        j                  t        j                   z  d       |j                  |dt        j                  t        j                   z  d       | je                  t        jf                  | jh                  | jH                         | je                  t        jf                  | jj                  | jJ                         | je                  t        jf                  | jl                  | jL                         | je                  t        jn                  | jp                  | j                         | je                  t        jn                  | jr                  |jt                         | je                  t        jn                  | jv                  | jV                         | je                  t        jx                  | jz                  |j|                  d3          |j                  |       |j                          |S )4Nr  r*  FTr  r  zVector legendr  zShow vector legendr   r  r  r   rn   r  r  zSource vector mapsr   r   z,Choose vector maps and their order in legendz
Vector mapro   Labelr  c                     | d   S Nrm   ri   rV   s    rH   <lambda>z,LegendDialog._vectorLegend.<locals>.<lambda>	  s
    qt rI   rd   rc  rq   rm   r  r  r  
Edit labelr   r   r   r   r  r   r   r   r  r  r"  rp   r  zdraw border around legendr   r   rH  r/  )Ar$   rD   r   r  r   r  r  r   r]  r  r   	isVLegendr   r  r  r  r  r&   r  r  r'   r   vectorListCtrlInsertColumnr  sortedr   
InsertItemGetItemCountr  SetItemSetItemData	CheckItemSetColumnWidthLIST_AUTOSIZEr   r  r  btnLabelr  r  r  r,  r5  r   FNTP_FONTDESC_AS_LABELborderColorCtrlr=  BLACKr>  rC   rX  r  r  OnEditLabelr@  r  r  	spanRadior  EVT_FONTPICKER_CHANGEDOnFontr0  r^  r`  )rG   r  r  r   rA  r  r  
vectorTextr  r  indexflexGridSizers               rH   r  zLegendDialog._vectorLegend  s   			AQAQ
 	ed;m$e!O*<=R[[)!%BIIQ?S=TU 0 0 ;<}-

4>>abffryy6HQR
S RYYfq9M7N.N
 !!#r{{3AA6biiq)W'X

 ,E2((AlO<((AgJ7==  /7^G " @++66''446q	8LQ8O ##++E1fQi@##//u=##--eT:!9>''11%?@ }}..q#6..q"2B2BC**1b.>.>?Ebiiqw?
e		6Cu!L/JFb6N6NWX 	 	
 	))BII5 	 	
 	JJF)A)A! 	 	
 	LLf2+C+CA 	 	
 	MMvB,D,DQ 	 	
 	##Aq)##Aq)		,1299Q	G

5QRVVbii-?
J 	%6R u&1X;:NO!!#r{{3((aaa@#biiq)D'E
  0biir'@'@ 
 H%/  **2884%%e,  **:d6F6Fx6P+QR%%d+1I1IRS 	 	
 	  QR5M5MVW 	 	
 			-ABFFRYY4Fq	Q

5QRVVbii-?
J		"--DJJ7		"--dll;		"--!1!14==A		"//4??DNNC		"//4;;@		"//4==$2B2BC		"++T[[%**Z:PQv		rI   c           	         |dk(  r| j                   }n| j                  }|}|}t        |t        j                  dt        d      z        }t        j                  |t        j                        }| j                  ||       t        j                  t        j                        }	|	j                  |j                  d   dt        j                  t        j                  z  d	       |	j                  |j                  d
   dt        j                  d	       |j                  |	dd       t        j                  t        j                        }
t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                   dd      }| j#                  ||       |j                  |j$                  d   dt        j                  d       |j                  |j$                  d   dt        j                  d       |j                  |j$                  d   dt        j                  d       |j                  |j$                  d   dt        j                  d       |j                  |j$                  d   ddt        j&                  d       |j)                  d       |j                  |dt        j*                  t        j                  z  d	       t-        |t        j                  t        d             }|d!   r.| j.                  j1                  t3        |d!         d"|d#   $      }nd%}t5        |t        j                  t7        |      t9        d&      '      |_        |j:                  j=                  t        d(             |dk(  rt-        |t        j                  t        d)             |_        |d*   r.| j.                  j1                  t3        |d*         d"|d#   $      }nd%}t5        |t        j                  t7        |      t9        d&      '      |_         t        j                   dd      | _!        | jB                  j                  |dt        j                  d       | jB                  j                  |j:                  dt        j                  d       | jB                  j                  |j>                  dt        j                  d       | jB                  j                  |j@                  dt        j                  d       |j                  | jB                  dt        j*                  t        j                  z  d	       |d+k(  rY|j:                  j=                  t        d,             d\  }}| jD                  r1d}tG        dtI        | jJ                  | jD                     d-               }t-        |t        j                  t        d.             }tM        |t        j                  d%|||d/   0      |_'        tQ        |t        j                  t        d1             |_)        t5        |t        j                  d%2      |_*        |jT                  j=                  t        d3             |d4   rm|jR                  jW                  d5       | j.                  j1                  t3        |d4         d"|d#   $      }|jT                  jW                  t7        |             n|jR                  jW                  d6       t        j                   dd      | _,        | jX                  j                  |dt        j                  d       | jX                  j                  |j:                  dt        j                  d       | jX                  j                  |dt        j                  d       | jX                  j                  |jN                  dt        j                  d       | jX                  j                  |jR                  dt        j                  d       | jX                  j                  |jT                  d7t        j                  d       | jX                  j[                  d       |j                  | jX                  dt        j*                  t        j                  z  d	       |
j                  |dt        j*                  t        j                  z  d8	       |
j                  |dt        j*                  t        j                  z  d8	       |j                  |
dt        j*                  d	       |j                  |dt        j                  t        j*                  z  d	       t        |t        j                  dt        d9      z        }t        j                  |t        j                        }t        j\                  ddd:      }|dk(  r| j_                  ||d5;       n| j_                  ||d6;       |j                  |j`                  d<   dt        j                  d	       |j                  |j`                  d=   dt        j                  d	       |j                  |j`                  d>   dt        j                  d	       |j                  |j`                  d?   dt        j                  d	       |dk(  r`|j                  |j`                  d@   dt        j                  d	       |j                  |j`                  dA   dt        j                  d	       |j[                  d       |j                  |dt        j                  t        j*                  z  d	       |j                  |dt        j                  t        j*                  z  d	       yB)Cz2Insert widgets for size, position and font controlr  r  zSize and positionr   r   r   r   r2  r  r   ro   rn   r  Positionr  r   r   r   r   r   r   r   r   r   r   r   r   r   r   rp   zWidth:r   r   r   r   r   r   rN   r   z2Leave the edit field empty, to use default values.Height:r   r  zAWidth of the color symbol (for lines)
in front of the legend textr  Columns:r  r   r   r4  r5  r6  zcolumn span:r  zXColumn separation distance between the left edges
of two columns in a multicolumn legendr   TFr   rm   Font settingsr  )r   r   r<  r*  r/  r,  r7  r9  r;  N)1r  r  r&   rD   r   r   r  r  r   r]  r  r  r   r  r  r  r  r   r   r  r  r  r'   r   r   r  r(   r   r>   	widthCtrlrY  heightOrColumnsLabelheightOrColumnsCtrlrSizeGBSizerr  r4  r  r   r%   colsCtrlr   r+  spanTextCtrlr   vSizeGBSizerr  r,  r@  r0  )rG   r  r   re  
legendDictr  r   rA  r  unitBoxr  posBoxposSizersizeBox	sizeSizerposGridBagSizerr   rk  hminVectmaxVectr  ri  	fontSizerrI  s                            rH   r  zLegendDialog.sizePositionFontd  s	   !))J))J RYYfq9L7M.M
 !!#r{{3Uz:++bmm,KK%))BGG3	 	 	
 	EKK,PQR		'a	2{{2==)%BIIVa
m=ST$$VR[[95RYYfqy>PQ%%gr{{;	//r: 	*=NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN9% 	 	
 	&&q)_RVV9KTUV 5RYYakBg%%Jw/0!&) & A A"biis1v\9R
 	""BC	
 ! *4"))1Y<*E& (#MM))
8 45#%f- *  (0"))3q6[=V)E% !#QQ ?D!!6(@(@ "  !!V"2J2JST "  !!**--	 "  !!))--	 "  MM!!abii"&&6HQR   !OO&&VW  $GW}}b#d&6&6t}}&Ef&M"NOe		:GD%99"6*EN 'u!NBSTEO!)%BIIR!HE))= &!((.MM))
6 23#%f- * 
 ""++CF3((/ "QQ ?D!!6(@(@ "  !!V"2J2JST "  !!&r'?'? "  !!F1I1IRS "  !!V"2J2JST "  !!""R5M5MVW "  ,,Q/MM!!abii"&&6HQR   	abii"&&.@Kqryy266/A!L		$1299Q	?

5QRVVbii-?
J u&1_CU:UV%%c2;;7	$$!!!<	!LL*DLILL*ELJJJ{#))	 	 	
 	JJz"))	 	 	
 	JJ'))	 	 	
 	JJ~&))	 	 	
 !MM

<(--	   MM

;'--	   	  #iABFFRYY4FqQ

9"))1CA
NrI   c                    | j                   j                         }|dk(  s|| j                  j                         }| j                  j                         rWt        |      D ]  \  }}|j                           | j                  d       | j                  d       | j                  d       n+|D ]&  }|j                         dk7  s|j                          ( |dk(  s|| j                  j                         }| j                  j                         rFt        |      D ]  \  }}|j                           | j                  d       | j!                  d       y|D ]&  }|j                         dk7  s|j                          ( yy)zOEnables and disables controls, it depends if raster or vector legend is checkedr   Nr  ro   r  )r  r  r  r>  r  rP   r  r  r  r  r  r  r  r  r  r  r  )rG   rc   r  childrenr  r  s         rH   r  zLegendDialog.OnIsLegendX  sG   }}))+19''335H~~&&(!*8!4 $IAvMMO$d#T"%& )F~~'=8() 19''335H~~&&(!*8!4 $IAvMMO$D!d#& )F~~'=8() &rI   c                 r   | j                   j                         r0| j                  j                          t	        | j
                        }n?| j                  j                          | j                  j                         }t	        |      }|dk(  r| j                  j                  d       n|dv r| j                  j                  d       |[| j                  d   dk(  r| j                  j                  d       n-| j                  d   dk(  r| j                  j                  d       | j                  d        y )NCELLT)FCELLDCELLr  r~   rh  )r  rP   r  r  r  r  r  r  r   r  r  r  )rG   rc   r  r  s       rH   r  zLegendDialog.OnRasters  s    &&(%%' 1D$$&##,,.C %D6>MM""4(''OO$$T*=
+s2&&t,!!*-4((.rI   c           	         | j                   j                  j                         }| j                   j                  j                          | j                  j                         rP| j                   j                  j                  t        d             t        | j                   t        j                  ddd| j                  d         | j                   _        | j                   j                  j                  |       | j                  j                          | j                  j!                          | j"                  j!                          | j$                  j!                          | j&                  j!                          | j(                  j!                          | j*                  j!                          n| j                   j                  j                  t        d             | j                  d   rB| j,                  j/                  t1        | j                  d         d	| j                  d
         }nd}t3        | j                   t        j                  t5        |      t7        d            | j                   _        | j                   j                  j                  |       | j                  j!                          | j                  j                          | j                  j                         rh| j&                  j                          | j(                  j                          | j"                  j                          | j$                  j                          | j*                  j                          | j8                  j;                  | j                   j                  dt        j<                  d       | j                   j?                          | j                   jA                          y)z.Change control according to the type of legendr4  r   ro   r2  r  r5  r3  r   r   r   r   rN   r   r   r   r   N)!r  r9  	IsEnabledrO  r  rP   r8  r  r   r%   rD   r   r  r  r  r  r  r4  r5  r  r  r	  r   r   r  r(   r   r>   r:  r  r  r_  r`  )rG   rc   enabledSizerE  s       rH   r  zLegendDialog.OnDiscrete  s   &&::DDF,,446==!!#11::1Z=I3;  99((04D0 0077DKK JJ HHHHLL  "LL  "JJ 11::1Y<H)MM)) 0 0 :;#++F3 *  3;  99!f%l3	4D0 0077DKK!JJzz""$##%##%!!JJ00))	 	 	
 	!rI   c                    | j                   j                         si| j                  j                          | j                  j                          | j
                  j                          | j                  j                          y | j                  j                          | j                  j                          | j
                  j                          | j                  j                          y r@   )r  rP   r4  r  r5  r  r  r  rK  s     rH   r  zLegendDialog.OnRange  s    zz""$HHHHLL  "LL  "HHOOHHOOLL!LL!rI   c                    | j                   j                         dk7  r| j                   j                         }|r| j                   j                  |      dz
  }| j                   j                  |dz
        dz   }| j                   j                  ||       | j                   j                  |dz
  |       | j                   j	                  t
               |dkD  r|dz
  }nd}| j                   j                  |       yyy)z5Moves selected map up, changes order in vector legendr   ro   r   N)r  GetFirstSelectedGetItemDatar"  	SortItemscmpr
   rG   rc   r   idx1idx2rN  s         rH   r  zLegendDialog.OnUp  s    //1R7%%668C**66s;a?**66sQw?!C##//T:##//a>##--c27"QwH H##**84  8rI   c                    | j                   j                         dk7  r3| j                   j                         }|| j                   j                         dz
  k7  r| j                   j                  |      dz   }| j                   j                  |dz         dz
  }| j                   j	                  ||       | j                   j	                  |dz   |       | j                   j                  t               || j                   j                         dz
  k  r|dz   }n| j                   j                         dz
  }| j                   j                  |       yyy)z7Moves selected map down, changes order in vector legendr   ro   N)r  rT  r   rU  r"  rV  rW  r
   rX  s         rH   r  zLegendDialog.OnDown  s#   //1R7%%668Cd))6681<<**66s;a?**66sQw?!C##//T:##//a>##--c2,,99;a??"QwH#22??AAEH##**84 = 8rI   c                 (   | j                   j                         dk7  r| j                   j                         }| j                   j                  |d      j                         }t	        | t        d      t        d      |t        j                  t        j                  z  t        j                  z        }|j                         t        j                  k(  r-|j                         }| j                   j                  |d|       |j                          yy)z!Change legend label of vector mapr   ro   zEdit legend label:r  )r  r  r   r   N)r  rT  r  GetTextr)   r   rD   r  CANCELCENTREr  rU  rP   r!  rO  )rG   rc   r  defaultr  news         rH   r*  zLegendDialog.OnEditLabel  s    //1R7%%668C))11#q9AACG!./,eebii'"))3C }}"((*lln##++CC8KKM 8rI   c                     | j                   j                  j                  | j                   j                  j	                                y r@   )r  r<  r  r+  rP   rK  s     rH   r  zLegendDialog.OnSpan  s1    %%,,T-=-=-G-G-P-P-RSrI   c                 h   | j                   j                  d   j                         }| j                  j	                  | j                   j
                  d   j                               }|dz  }| j                  j                  |d|      }| j                   j                  j                  d|z         y)zKChanges default width according to fontsize, width [inch] = fontsize[pt]/24r7  r   g      8@r   r   z%3.2fN)
r  r0  rP   r   r  r   r  r   r7  r   )rG   rc   r8  r   rk  r   s         rH   r-  zLegendDialog.OnFont  s     ##((8AAC}}%%"";/BBD
 tO%%At%L""++GeO<rI   c                 j    | j                   j                  | j                  j                                y)z+Enables/disables colorPickerCtrl for borderN)r(  r  r5  rP   rK  s     rH   r  zLegendDialog.OnBorder  s%    ##D$4$4$=$=$?@rI   c           	         | j                   j                         sd| j                  d<   nd| j                  d<   | j                  j	                  | j
                  j                  d   j                               }|| j                  d<   | j                  j                         r)d| j                  d<   | j                  | j                  d<   n6d| j                  d<   | j                  j                         | j                  d<   | j                  d   rY| j                  d   sJt        j                  t        d      t        d	      t        j                  t        j                  z  
       y| j                  d   rt!        | j                  d         }|y|| j                  d<   | j"                  j                         rd| j                  d<   nd| j                  d<   | j
                  j$                  d   j                         | j                  d<   | j
                  j$                  d   j                         | j                  d<   | j
                  j$                  d   j'                         }t)        |      | j                  d<   | j                  j+                  t-        | j
                  j.                  d   j                               |d      }| j                  j+                  t-        | j
                  j.                  d   j                               |d      }||f| j                  d<   | j
                  j0                  j                         }	 t-        |      }| j                  j+                  ||d      }|| j                  d<   | j                  d   dk(  r^| j
                  j4                  j                         }	 t-        |      }| j                  j+                  ||d      }|| j                  d<   n3| j
                  j4                  j                         }|| j                  d<   | j6                  j9                  | j                  d   | j                  d   | j                  d   | j                  d   | j                  d         }	| j6                  j;                  | j                  d   | j                  d   | j                  d   | j                  d   | j                  d   | j<                  | j>                           }
tA        |||
|	       | j                  d!<   | j                  d   dk(  r:| jB                  j                         rd| j                  d"<   nd| j                  d"<   n| j                  d   dk(  r| jD                  j                         rd| j                  d#<   nd| j                  d#<   | jF                  j                         r^d| j                  d$<   | jH                  j                         | j                  d%<   | jJ                  j                         | j                  d&<   nd| j                  d$<   | jL                  d'   | j<                  vr?tO        | jL                  d'   | jP                  (      }| j<                  jS                  |       | j<                  | jL                  d'      jU                  | j                         | jL                  d'   | jV                  jX                  vr2| jV                  jX                  j[                  | jL                  d'          y# t2        $ r d}Y w xY w# t2        $ r d}Y ^w xY w))z8Save information from raster legend dialog to dictionaryFr  Tr   r   r  r  zNo raster map selected!z	No rasterr  Nr  r~   r  rh  r/  r0  r7  r8  r;  r<  r   r   r   r   r   r   r   r  )r  r  r8  r  r   )r  r  r8  r  r   
paperInstrrV   r~   r   r   r   r  r  r  r4  r5  r   r  ).r  rP   r  r   r  r  r   r  r  r  r  rD   r  r   r  r  r  r  r0  r~  r>  r   r  r   r7  r  r9  r  EstimateHeightEstimateWidthr   r  Rect2Dr  r	  r  r4  r5  r   r  r   rr  r  r   r  r  )rG   r  r  r<  rV   r~   r   r   r  
drawHeight	drawWidthr  s               rH   updateRasterLegendzLegendDialog.updateRasterLegend  su    ~~&&(*/DY'*.DY'==))"";/BBD
 $, &&(04D_-)-DX&05D_-)-):):)C)C)EDX&I&t/?/?/IMM34+eebmm+
 H%&t'7'7'ABJ!'1DV$ }}%%'/2  ,/2  , (,'7'7'<'<(  " V$ ,0+;+;+@+@,hj Z( $$))+6@@BE(25(9DW% %%D,,55g>GGIJ! & A
 %%D,,55g>GGIJ! & A
 *+ADW%$$..779Ee--(6 . 
 ).DW%
+s2))==FFH""6]F!]]22$x 3 F
 .4  *'';;DDF+/  (**99''1))*5))*5%%f-''1 : J ))77''1))*5))*5%%f-&&w/++DKK8 8 I (.q	*(DV$
 
+s2;;'')14D$$X.14D$$X.!!*-4::&&(25D$$Y/25D$$Y/::&&(04D$$W-.2hh.?.?.AD$$U+.2hh.?.?.AD$$U+05D$$W-wwqzT---'
AL++L9$33D4D4DE771:T[[111KK  ''
3}   " "!F"s$   )\( )\: (\76\7:]	]	c                    | j                   j                  d      }|r|j                  | _        nd| _        | j                  j                         sd| j                  d<   nd| j                  d<   | j                  d   r| j                  d}t        | j                  j                               D ][  }| j                  j                  |      r"| j                  j                  ||       |dz  }@| j                  j                  |d       ] |dk(  rd| j                  d<   nE| j                   | j                     d   }t        |      D ]  \  }}| j                  j                  d	|d   j                  d
      d         }| j                  j                  |      ||   d<   | j                  j!                  |d      j#                         ||   d<    | j                   j                  dd      }t%        ||      D ]C  \  }}|d   | j                   |j                     d<   |d   | j                   |j                     d<   E | j&                  j)                  | j*                  j,                  d   j/                               }|| j                  d<   | j&                  j1                  t3        | j*                  j4                  d   j                               |d      }	| j&                  j1                  t3        | j*                  j4                  d   j                               |d      }
|	|
f| j                  d<   | j*                  j6                  d   j/                         | j                  d<   | j*                  j6                  d   j                         | j                  d<   t9        |       }|j;                  t=        j>                  | j                  d   t<        j@                  t<        jB                  t<        jD                               | j&                  j1                  t3        | j*                  jF                  j                               |d      }|| j                  d<   | j*                  jH                  j                         | j                  d<   | j*                  jJ                  j                         rV| j*                  jL                  j                         r2| j*                  jL                  j                         | j                  d <   nd| j                  d <   | j                   | j                     d   }|D cg c]  }|d   dk7  s|d    }}|jO                  tQ        |tR        !            }| j&                  j1                  |d   d"d      }| j&                  j1                  |d   d"d      }||z   | j                  d   z  }tS        |      |z  | j                  d   z  }|d#z  }tU        |	|
||      | j                  d$<   | jV                  j                         r3| jX                  j[                         }t]        |      | j                  d%<   nd&| j                  d%<   | j                  d   | j                   vr?t_        | j                  d   | j`                  '      }| j                   jc                  |       | j                   | j                  d      je                  | j                         | j                  d   | jf                  jh                  vr2| jf                  jh                  jk                  | j                  d          yc c}w )(z8Save information from vector legend dialog to dictionaryr  NFr  Tro   r   r  r   rc  )startr   rm   rq   r  r  rf  r   r   r   r   r   r   r   r   r/  r0  r7  r8  )	pointSizefamilyr   weightr   r  r   r  pixelg?r   r   rH  r  )6r   rp  r   r  r  rP   r  r  r  r   IsItemCheckedr"  r  FindItemr  rU  r  r]  r|  r   r  r  r   r  r   r  r   r0  r   SetFontrD   FontFONTFAMILY_DEFAULTFONTSTYLE_NORMALFONTWEIGHT_NORMALr7  r;  r+  r<  r)  r5  r  rj  r5  r(  r~  r>  r  r   rr  r  r   r  r  )rG   r  r  r   vListr  vmapsr  r  rV   r~   r   r   r  r  extentwExtenthExtentrk  rE  r<  r  s                         rH   updateVectorLegendzLegendDialog.updateVectorLegend  s    !!77A"IIDM DM ~~&&(*/DY'*.DY'I&4==+D Cd11>>@A =&&44T:''33D#>1HC''33D!<= ax.3  +((7?!*5!1 QIAv..77 fQiooc&:1&= 8 D #'"5"5"A"A$"GE!HQK"&"5"5"="=dA"F"N"N"PE!HQKQ ((>>}SW>X$'u$5 CLD&8>q	D$$TWW-f59?D$$TWW-g6C  ==11$$**;7JJL ,4  (MM)) 0 0 9 9' B K K MN%! * 
 MM)) 0 0 9 9' B K K MN%! * 
 ./F  ) ,0+;+;+@+@,$$&   ( 04/?/?/D/D"0(*   , d^

GG"&"2"2:">!44 11!33	 -- 0 0 : : C C EF%! . 
 -2  )+/+;+;+D+D+M+M+O  ($$..779((55>>@/3/?/?/L/L/U/U/WD$$V,/3D$$V, **4==9&A29LVAY!^&)LL))#f#*>?--// )gf 0  --// )gf 0  W_(8(8(@@K')D,<,<V,DDS+1!Q1+=  ( ##,,. 00::<E1;E1BD$$X. 28D$$X.wwqzT---'
AL++L9$33D4D4DE771:T[[111KK  ''
37 Ms   ]]c                 N    | j                         }| j                         }|r|ryyr  )rm  r  )rG   r  r  s      rH   rB  zLegendDialog.update  s)    %%'%%'3rI   c                    d| j                   v r| j                   d   dd \  }}| j                  j                  | j                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j                  j                  d   j                  d|z         | j                  j                  d	   j                  d|z         | j                  j                  d
      }|r|j                  | _        nd| _        |r|d
   }nd}t        |      }| j                  j                  t!        d      |t#        |      dz         d| j$                  v r| j$                  d   dd \  }}| j                  j                  | j&                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j&                  j                  d   j                  d|z         | j&                  j                  d	   j                  d|z         | j                  j                  d      rt)        | j                  j                  d      d   d       }| j*                  j-                          |D ]  }| j*                  j/                  | j*                  j1                         |d   j3                  d      d         }	| j*                  j5                  |	d|d          | j*                  j7                  |	|	       | j*                  j9                  |	d       |d   dk(  s| j*                  j9                  |	d        | j&                  j:                  j=                  dt?        dtA        | j                  j                  d      d                      | j&                  j:                  j                  d       y| j*                  j-                          | j&                  j:                  j=                  dd       | j&                  j:                  j                  d       y)z&Update legend coordinates after movingr   Nrp   r   r   r   r   r   r   r  r  r  r  r  r  c                     | d   S r  ri   r  s    rH   r  z+LegendDialog.updateDialog.<locals>.<lambda>A  s
    ad rI   r  r   rc  ro   rq   Trm   Fr2  )!r  r   r  r  r   r  r   r   r   r   rp  r   r  r  r  r  r   r   r  r  r  r  DeleteAllItemsr  r   r  r!  r"  r#  r;  SetRanger4  r  )
rG   rV   r~   r  r  r  r  r  r  r/  s
             rH   r  zLegendDialog.updateDialog  s    T%%%##F+BQ/DAq}}--  &&{3FFHH %%Ax%PA%%Ax%PA%%g.77!D%%g.77!D!!77A"IIDM DM)JJ"z2
##'(JJ+XX	

 T%%%##F+BQ/DAq}}--  &&{3FFHH %%Ax%PA%%Ax%PA%%g.77!D%%g.77!D11(;  66x@H"G ..0! @++66''446q	8LQ8O ##++E1fQi@##//u=##--eT:!9>''11%?@ %%..BD,,BB8LVTUV %%..q1..0%%..q!4%%..q1rI   N)re   rf   rg   rA   r  r  r  r  r  r  r  r  r  r  r*  r  r-  r  rm  r  rB  r  ri   rI   rH   r  r    ss    COJ	
m^yvpOh)6(7r
"5"5""T	=ADLun@2rI   r  c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)MapinfoDialogc                    t         j                  | ||t        d      ||       d| _        | j                  >| j
                  | j                     | _        | j                  j                         | _        nt               | _        t        | j                  | j                        | _        | j                  j                         | _        | j
                  j                  d      j                         }|d   |d   f| j                  d<   | j                         | _        | j                  | j                         | j!                  d        | j#                  d        y )	NzMapinfo settingsrk  )mapinfor  r  rq  rs  r   )r   rA   r   r   r   r   r  r  mapinfoDictr  Mapinfor   rp  _mapinfoPanelr  rf  OnIsBackground
OnIsBorderrG   r   r   r   r   r  s         rH   rA   zMapinfoDialog.__init__Y  s   &' 	 	
 '77++DGG4DL#||::<DgDG"4779DL#||::<D##99&APPRD(,Vd5k(ADW%'')
TZZ D!rI   c                 z   t        | t        j                  dt        j                        }t        j                  t        j
                        }t        |t        j                  dt        d      z        }t        j                  |t        j
                        }t        j                  dd      }| j                  || j                         | j                  || j                         |j                  |j                  d	   d
t        j                  d       |j                  |j                  d   dt        j                  d       |j                  |j                   d   dt        j                  d       |j                  |j                   d   dt        j                  d       |j                  |j                   d   dt        j                  d       |j                  |j                   d   dt        j                  d       |j                  |j                   d   ddt        j"                  d       |j%                  d       |j                  |dt        j&                  t        j(                  z  d       |j                  |dt        j(                  t        j&                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j
                        }t        j                  dd      }| j+                  || j                         |j                  |j,                  d   d
t        j                  d       |j                  |j,                  d   dt        j                  d       |j                  |j,                  d    dt        j                  d       |j                  |j,                  d!   dt        j                  d       |j                  |j,                  d"   dt        j                  d       |j                  |j,                  d#   dt        j                  d       |j%                  d       |j                  |dt        j(                  t        j&                  z  d       |j                  |dt        j(                  t        j&                  z  d       t        |t        j                  dt        d$      z        }t        j                  |t        j
                        }t        j.                  d%dd&      }i | _        t3        |t        j                  t        d'      (      | j0                  d)<   t3        |t        j                  t        d*      (      | j0                  d+<   t5        |t        j                  ,      | j0                  d-<   t5        |t        j                  ,      | j0                  d.<   | j                  d/   d0| j                  d/<   | j                  d/   d0k7  rS| j0                  d)   j7                  d1       | j0                  d-   j9                  t;        | j                  d/                nE| j0                  d)   j7                  d2       | j0                  d-   j9                  t;        d3             | j                  d4   | j                  d4   d0k(   | j                  d4   d0k7  rS| j0                  d+   j7                  d1       | j0                  d.   j9                  t;        | j                  d4                nE| j0                  d+   j7                  d2       | j0                  d.   j9                  t;        d5             |j                  | j0                  d)   dt        j                  d       |j                  | j0                  d-   dt        j                  d       |j                  | j0                  d+   dt        j                  d       |j                  | j0                  d.   dt        j                  d       |j%                  d       |j                  |dt        j(                  t        j&                  z  d       |j                  |dt        j(                  t        j&                  z  d       |j=                  |       | j?                  t        j@                  | jB                  | j0                  d)          | j?                  t        j@                  | jD                  | j0                  d+          |S )6Nr)  r*  r  r2  r   rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ro   r  r6  r*  r/  r,  r7  r9  r;  zColor settingsrp   r  zuse border color:r   
borderCtrlzuse background color:backgroundCtrlr:  borderColorbackgroundColorr   rH  TFr.   
backgroundr;   )#r!   rD   r   r  r]  r  r&   r   r  r  r   r  r   r  r   r  r   r  r  r  r  r@  r0  r,  colorsr   r   r   r=  r>  r^  rC   r@  r  r  )rG   r  r   rA  r  r  rI  s          rH   r  zMapinfoDialog._mapinfoPanelt  s   TbiihbFVFVWR[[) u&1Z=:PQ!!#r{{3AA6$2B2BCUt/?/?@KK%))	 	 	
 	KK$))	 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN9% 	 	
 	##A&		,1299rvv3Ea	P

5QRVVbii-?
J u&1_CU:UV!!#r{{3AA6 	Ed.>.>?JJ{#b6N6NWX 	 	
 	JJz"R5M5MVW 	 	
 	JJ'))	 	 	
 	JJ~&))	 	 	
 	JJ|$))	 	 	
 	JJ{#b6N6NWX 	 	
 	##A&		,1266BII3Ea	P

5QRVVbii-?
J u&1EUCV:VW!!#r{{3$$!!!<	$,biiq)<'=%
L! )1biiq)@'A)
$% &6e		%JM")9%BII)N%&H%-)/DX&H%/KK%..t4KK&00D<L<LX<V1WXKK%..u5KK&00G1DEL)1\*f4L)V3KK()2248KK)*444++L9: KK()2259KK)*44Z5HIKK%))	 	 	
 	KK&))	 	 	
 	KK()))	 	 	
 	KK)*))	 	 	
 	  #		)0B1	M

5QRVVbii-?
Jv		"//4??DKK4MN		"//4#6#6DT8UVrI   c                     | j                   d   j                         r.| j                   d   j                          | j                          y | j                   d   j	                          y Nr  r  r  rP   r  rB  r  rK  s     rH   r  zMapinfoDialog.OnIsBackground  M    ;;'(113KK)*113KKMKK)*224rI   c                     | j                   d   j                         r.| j                   d   j                          | j                          y | j                   d   j	                          y )Nr  r  r  rK  s     rH   r  zMapinfoDialog.OnIsBorder   sJ    ;;|$--/KK&--/KKMKK&..0rI   c                    | j                   j                  | j                  j                  d   j	                               }|| j
                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j
                  d   d   }| j                  j                  d   j                         r(| j                  j                  d   j                         }n| j
                  d   d   }| j                   j                  t        | j                  j                  d   j                               |d	      }| j                   j                  t        | j                  j                  d   j                               |d	      }||f| j
                  d<   | j                  j                  d
   j	                         | j
                  d<   | j                  j                  d   j                         | j
                  d<   | j                  j                  d   j                         }t        |      | j
                  d<   | j                  d   j                         r6| j                  d   j                         }t        |      | j
                  d<   nd| j
                  d<   | j                  d   j                         r6| j                  d   j                         }t        |      | j
                  d<   nd| j
                  d<   | j                  j                  | j
                        | j
                  d<   | j                   | j"                  vr<t%        | j                   | j&                        }| j"                  j)                  |       | j"                  | j                      j+                  | j
                         | j                   | j,                  j.                  vr/| j,                  j.                  j1                  | j                          | j3                          y)Nr   r   r   r   r   r   ro   r   r   r/  r0  r7  r8  r;  r<  r  r  r  rH  r  r  r   r   r  T)r   r  r  r   r  r  r   rP   r   r  r0  r~  r>  r  r  EstimateRectr   r   r  r   rr  r  r   r  r  r  )rG   r  rV   r~   r<  r  r   r  s           rH   rB  zMapinfoDialog.update'  s^   ==))JJ[)<<>
 $,  ::w'002

##G,557A  )!,A::w'002

##G,557A  )!,AMM!!

++G4==?@ " 

 MM!!

++G4==?@ " 

 &'F! $(::??:#>#Q#Q#S '+zz~'F'O'O'Q$ 

,668$.u$5!;;'(113%67AACJ-7
-CD\*-3D\*;;|$--/[[/99;F)3F);DX&)/DX& $(<<#<#<T=M=M#N 77$***dgg4884G++G4!001A1AB77$++...KK  ''0rI   c                    | j                   d   \  }}| j                  j                  | j                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j                  j                  d   j                  d|z         | j                  j                  d   j                  d|z         y)	z(Update mapinfo coordinates, after movingr   r   r   r   r   r   r   N)	r  r   r  r  r   r  r   r   r   rG   rV   r~   r  s       rH   r  zMapinfoDialog.updateDialogi  s    (1==))JJ[)<<>
 MM!!F8!LMM!!F8!L

G$--gk:

G$--gk:rI   N)	re   rf   rg   rA   r  r  r  rB  r  ri   rI   rH   r  r  X  s$    6cJ51@D	;rI   r  c                   (    e Zd ZdZd Zd Zd Zd Zy)ScalebarDialogzDialog for scale barc                    t         j                  | ||d||       d| _        | j                  4| j                  |   | _        | j
                  j                         | _        nt               | _        t        | j                  | j                        | _        | j
                  j                         | _        | j                  j                  d      j                         }|d   |d   f| j                  d<   | j                         | _        | j                  | j                         t               d	   j!                         | _        t               d
   dk(  rd| _        | j"                  | j$                  j'                         vrd| _        y y )NzScale bar settingsrk  )scalebarr  r  rq  rs  r   r   r$  xymeters)r   rA   r   r   r   r  r  scalebarDictr  Scalebarr   rp  _scalebarPanelr  rf  r:  lowermapUnitr   getAllUnitsr  s         rH   rA   zScalebarDialog.__init__x  sC   & 	 	
 (77 ,,R0DM $ < < >DgDG$TWW$((;DM $ < < >D##99&APPRD)-ftE{)BDg&((*
TZZ z'*002:f%#DL<<t}}88::#DL ;rI   c                    t        | t        j                  t        j                        }t        j                  t        j
                        }t        |t        j                  dt        d      z        }t        j                  |t        j
                        }t        j                  dd      }| j                  || j                         | j                  || j                         | j                  d   r | j                  j                  | j                  d	   d
   | j                  d   j                         d   dz  z
  d| j                  d         }| j                  j                  | j                  d	   d   | j                  d   j                         d   dz  z
  d| j                  d         }|j                   d   j#                  d|z         |j                   d   j#                  d|z         |j%                  |j&                  d   dt        j(                  d
       |j%                  |j&                  d   dt        j(                  d
       |j%                  |j                   d   dt        j(                  d
       |j%                  |j                   d   dt        j(                  d
       |j%                  |j                   d   dt        j(                  d
       |j%                  |j                   d   dt        j(                  d
       |j%                  |j                   d   d d!t        j*                  d
"       |j-                  d       |j%                  |dt        j.                  t        j0                  z  d#       |j%                  |d
t        j0                  t        j.                  z  d#       t        |t        j                  dt        d$      z        }t        j                  |t        j
                        }t        j                  dd      }t3        |t        j                  t        d%      &      }t3        |t        j                  t        d'      &      }	t5        |t        j                  t7        d(      )      | _        | j8                  j;                  t        d*             t5        |t        j                  t7        d(      )      | _        | j<                  j;                  t        d+             t        d,      g| j                  j?                         z   }
tA        |t        j                  |
-      | _!        | j                  jE                         }
tA        |t        j                  |
-      | _#        | j                  jI                  | j                  d.         }|r| jB                  jK                  |       nt| j                  d.   d/k(  r| jB                  jM                  d
       nF| j                  d.   d0k(  r4| jB                  jK                  | j                  jI                  d1             | jF                  jK                  | j                  jI                  | j                  d2                | j                  d3   r2| j8                  j#                  tO        | j                  d3                n}tQ        jR                  | jT                  4      }tW        |d5   |d6   z
  dz        }tY        |t[        tO        |             dz         }| j8                  j#                  tO        |             | j                  j                  | j                  d7   d| j                  d2         }| j<                  j#                  tO        |             |j%                  |dt        j(                  d
       |j%                  | j8                  dt        j(                  d
       |j%                  | jB                  d8t        j(                  t        j.                  z  d
       |j%                  |	dt        j(                  d
       |j%                  | j<                  dt        j(                  d
       |j%                  | jF                  d!t        j(                  t        j.                  z  d
       |j-                  d       |j%                  |dt        j.                  t        j0                  z  d#       |j%                  |d
t        j0                  t        j.                  z  d#       t        |t        j                  dt        d9      z        }t        j                  |t        j
                        }t        j                  dd      }t3        |t        j                  t        d:      &      }t]        |t        j^                  ;      | _0        tb        jd                  jg                  th        jj                  d<      tb        jd                  jg                  th        jj                  d=      f}tm        d>d?g|      D ]g  \  }}tb        jd                  jo                  |      stq        d
d
      }nt        jr                  |      }| j`                  ju                  d@||d
   A       i | j                  dB   dCk(  r| j`                  jM                  d
       n-| j                  dB   dDk(  r| j`                  jM                  d       t3        |t        j                  t        dE      &      }tw        |t        j                  ddFdGH      | _<        | jx                  j#                  | j                  dI          t3        |t        j                  t        dJ      &      }t3        |t        j                  t        dK      &      }tw        |t        j                  ddFdH      | _=        | jz                  j#                  | j                  dL          t3        |t        j                  t        dM      &      }tw        |t        j                  dGdFdNH      | _>        | j|                  j#                  | j                  dO          t        |t        j                  t        dP      &      | _@        | j                  dQ   dRk(  r| j                  j#                  dS       n| j                  j#                  dT       |j%                  |dt        j(                  d
       |j%                  | j`                  dd!t        j(                  t        j.                  z  d
"       |j%                  |dt        j(                  d
       |j%                  | jx                  dt        j(                  d
       |j%                  |dt        j(                  d
       |j%                  | jz                  dt        j(                  d
       |j%                  |dUt        j(                  d
       |j%                  |d t        j(                  d
       |j%                  | j|                  dVt        j(                  d
       |j%                  | j                  dWdXt        j(                  d
"       |j%                  |ddY       |j%                  |d
t        j0                  t        j.                  z  d#       |j                  |       |S )ZNr  r  r2  r   rn   r   r   r   r   r   rp   r   r   r   ro   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  zLength:r   r3  rN   )r   r   z%Scalebar length is given in map unitsz'Scalebar height is real height on paperr`  r   unitsLengthauto	nautmilesnautical milesunitsHeightlengthr  rj  rk  r   r  StylezType:)r   zscalebar-fancy.pngzscalebar-simple.pngfancysimpler   )r   rq  
clientDatar  fri  zNumber of segments:r   rq   r3  segmentzLabel every segmentsnumbersr+  r2  r8  ztransparent text backgroundr  r~   FTr#  r  r!  r   r  )Br!   rD   r   r  r]  r  r&   r   r  r  r   r  r   r   r   Getr   r   r  r   r  r  r  r  r  r'   r(   r>   lengthTextCtrlrY  heightTextCtrlgetMapUnitsNamesr   r  r   r  r   r   r  r   rn  r  r   r}   r  r  r   CB_READONLYsbCombor  r  ru  r   IMGDIRr|  existsr   r  Appendr%   sbSegmentsCtrlsbLabelsCtrlfontsizeCtrlr   backgroundCheckr^  )rG   r  r   rA  r  r  rV   r~   
lengthText
heightTextr   unitNameregrk  rE  
sbTypeText	imagePathr   r  rq  sbSegmentsTextsbLabelsText1sbLabelsText2fontsizeTexts                           rH   r  zScalebarDialog._scalebarPanel  s4   Tbiir7G7GHR[[) u&1Z=:PQ!!#r{{3AA6Ut/@/@A$2C2CD
 %%''03##F+//1!4q89((0	 & A %%''03##F+//1!4q89((0	 & A NN7#,,Wq[9NN7#,,Wq[9KK%))	 	 	
 	KK$))	 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN8$))	 	 	
 	NN7#b6N6NWX 	 	
 	NN9% 	 	
 	##A&		,1299rvv3Ea	P

5QRVVbii-?
J u&1V9:LM!!#r{{3AA6"))1Y<H
"))1Y<H
&bii;|+D
 	&&q)P'QR&bii;|+D
 	&&q)R'STY<.4==#A#A#CC!%BIIwG--113!%BIIwG ==))$*;*;M*JK//9  /69  --a0""=1[@  33MM**+;< 	++MM""4#4#4]#CD	
 X&((T->->x-H)IJ,,488,CSXC(A-.Aa#c!f+)*A((Q0MM!!##H-$$]3 " 

 	$$SV,F)A)A! 	 	
 	V"2J2JST 	 	
 	))BII5	 	 	
 	F)A)A! 	 	
 	V"2J2JST 	 	
 	))BII5	 	 	
 	##A&		,1299rvv3Ea	P

5QRVVbii-?
J u&1W::MN!!#r{{3AA6"))1W:F
%e2>>BGGLL!1!13GH"'',,3K
 
	 w19= 	LJD$77>>$'$Q*4LLR47K	L Z(C/LL%%a(z*c1LL%%a(#EbiiqAV?WX&urSTU$$T%6%6y%AB"5RYYa>OP"5RYYa
mL$UryyaRQRS""4#4#4Y#?@ "%BIIQ|_M$UryyaRQST""4#4#4Z#@A'biiq)F'G 
 \*c1  ))%0  ))$/F)A)A! 	 	
 	LL))BII5 	 	
 	R-E-Ea 	 	
 	V"2J2JST 	 	
 	vB,D,DQ 	 	
 	60H0HQR 	 	
 	vB,D,DQ 	 	
 	f2+C+CA 	 	
 	60H0HQR 	 	
 	  )) 	 	
 			,1Q	7

5QRVVbii-?
JvrI   c                    | j                   j                  | j                  j                  d   j	                               }|| j
                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j
                  d   d   }| j                  j                  d   j                         r(| j                  j                  d   j                         }n| j
                  d   d   }| j                   j                  t        | j                  j                  d   j                               |d	      }| j                   j                  t        | j                  j                  d   j                               |d	      }| j                  j                  | j                  j                               | j
                  d
<   | j                  j                         | j
                  d<   | j                  j                         | j
                  d<   | j                  j                         | j
                  d<   | j                   j                         rd| j
                  d<   nd| j
                  d<   | j                   j                  | j"                  j	                               | j
                  d<   	 t        | j$                  j                               }| j                   j                  || j
                  d   d	      }|| j
                  d<   | j*                  j                         dk(  rd}n:| j                   j                  | j*                  j	                               }|dk(  rd}|| j
                  d<   	 t        | j,                  j                               }|| j
                  d<   | j8                  j;                  d      }|s| j8                  j;                  d      }|j<                  }| j>                  jA                  | j
                  | j8                  |   d          }	tC        |||	d   |	d   !      | j
                  d"<   | j
                  d"   jE                         | j
                  d<   | j<                  | j8                  vr<tG        | j<                  | jH                  #      }
| j8                  jK                  |
       | j8                  | j<                     jM                  | j
                         | j<                  | jN                  jP                  vr/| jN                  jP                  jS                  | j<                         y$# t&        t(        f$ r d}Y ^w xY w# t&        t(        f$ rL t/        j0                  t3        d      t3        d      t.        j4                  t.        j6                  z         Y yw xY w)%zSave information from dialogr   r   r   r   r   r   ro   r   r   r  r  r  r8  rh  r  r~   r  g?r   r  r  r  r  z"Length of scale bar is not definedr  r  Fr  r  initMapr   )r  r   rg  r   r  T)*r   r  r  r   r  r  r   rP   r   r  r  GetClientDatar  r  r  r  r  r  r  r  r{  r  r  rD   r  r   r  r  r   rp  r   r  EstimateSizerj  	GetCentrer  r   rr  r  r   r  r  )rG   r  rV   r~   r   rN  r  r  r  rectSizer  s              rH   rB  zScalebarDialog.update  s    ==))JJ[)<<>
 %-&!::w'002

##G,557A!!'*1-A::w'002

##G,557A!!'*1-AMM!!

++G4==?@ " 

 MM!!

++G4==?@ " 
 )-(B(BLL%%')
*% (,':':'C'C'E)$'+'8'8'A'A'C)$(,(9(9(B(B(D*%((*.1Dl+.1Dl+
 ,0==+A+A//1,
-(	4..779:F]]**t'8'8'GPV + F
 '-(# ((*a/H}}--d.>.>.Q.Q.STH++&+3-(	4..779:F '-(# 44U;""88CC==--**$2B2B52I'2R . 
 %+1HQK%
&! &*%6%6v%>%H%H%J'"77$***TXX6H++H5!001B1BC77$++...KK  ''0Y K( 	F	 K( 	MM>?/*eebmm+
 	s&   AU1  #V	 1VV	AW$#W$c                    | j                   d   dd \  }}| j                  j                  | j                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j                  j                  d   j                  d|z         | j                  j                  d	   j                  d|z         y)
z)Update scalebar coordinates, after movingr   Nrp   r   r   r   r   r   r   )	r  r   r  r  r   r  r   r   r   r  s       rH   r  zScalebarDialog.updateDialog  s      (!,1==))JJ[)<<>
 MM!!F8!LMM!!F8!L

G$--gk:

G$--gk:rI   N)re   rf   rg   rh   rA   r  rB  r  ri   rI   rH   r  r  u  s    $<unaF	;rI   r  c                   N    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y)
TextDialogc                 h   t         j                  | ||d||       d| _        | j                  #| j                  |   j                         | _        nt               | _        t        | j                  | j                        }|j                         | _        | j                  j                  d      j                         }|d   |d   f| j                  d<   | j                  j                  d	      }|s| j                  j                  d
      }|j                  | _        t        || j                  d   d   | j                  d   d   d| j                        \  | j                  d<   | j                  d<   t        | t        j                  t        j                         }| j#                  |      | _        | j'                  |      | _        | j+                  d        | j-                  d        | j/                  d        | j1                  d        | j3                  d        | j5                  |       y )NzText settingsrk  )r  r  r  rq  rs  r   r  r  r   ro   Tr  r&  r'  r  )r   rA   r   r   r   r  textDictr  Textr   rp  r  r  r   rD   r   r  
_textPanel	textPanel_positionPanelpositionPanelOnBackgroundOnHighlightr  OnPositionTyper!  rf  )	rG   r   r   r   r   r  r  r  r  s	            rH   rA   zTextDialog.__init__  s   ! 	 	
 $77 ,,R0??ADMgDGTXX.D //1DM##99&APPRD%)&\4;%>DMM'"44U;""88CCVV
8KmmG$Q'mmG$Q'9
5ft}}W5 4BIIR]]K2!00:$dD!XrI   c                 X   t        |t        j                  t        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        |t        j                  t        d            }t        |t        j                  | j                  d   	      | _        |j                  |d
t        j                   t        j"                  z  d       |j                  | j                  dt        j                   t        j"                  z  d       |j                  |d
t        j"                  t        j$                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j&                  dddd      }| j)                  || j                         |j                  |j*                  d   d
t        j                   d
       |j                  |j*                  d   d
t        j                   d
       |j                  |j*                  d   d
t        j                   d
       |j                  |j*                  d   d
t        j                   d
       |j                  |j*                  d   d
t        j                   d
       |j                  |j*                  d   d
t        j                   d
       |j-                  d       |j                  |dt        j"                  t        j$                  z  d       |j                  |d
t        j"                  t        j$                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j.                  dd      }i | _        t3        |t        j                  t        d            | j0                  d<   t5        |t        j                        | j0                  d<   t3        |t        j                  t        d            | j0                  d <   t5        |t        j                        | j0                  d!<   t7        |t        j                  | j8                  d
dd"      | j0                  d#<   t        |t        j                  t        d$            | j0                  d%<   t3        |t        j                  t        d&            | j0                  d'<   t5        |t        j                        | j0                  d(<   t7        |t        j                  | j8                  dd)d"      | j0                  d*<   t        |t        j                  t        d$            | j0                  d+<   | j                  d,   d-| j                  d,<   | j                  d,   d-k7  rS| j0                  d   j;                  d.       | j0                  d   j=                  t?        | j                  d,                nE| j0                  d   j;                  d/       | j0                  d   j=                  t?        d0             | j                  d1   d-| j                  d1<   | j                  d1   d-k7  rS| j0                  d    j;                  d.       | j0                  d!   j=                  t?        | j                  d1                nE| j0                  d    j;                  d/       | j0                  d!   j=                  t?        d2             | j0                  d#   j;                  tA        tC        | j                  d3                      | j                  d4   d-| j                  d4<   | j                  d4   d-k7  rS| j0                  d'   j;                  d.       | j0                  d(   j=                  t?        | j                  d4                nE| j0                  d'   j;                  d/       | j0                  d(   j=                  t?        d5             | j0                  d*   j;                  tA        tC        | j                  d6                      |j                  | j0                  d   d7t        j                   d
8       |j                  | j0                  d   d9t        j                   d
8       |j                  | j0                  d    d:t        j                   d
8       |j                  | j0                  d!   d;t        j                   d
8       |j                  | j0                  d%   d<t        j                   d
8       |j                  | j0                  d#   d=t        j                   d
8       |j                  | j0                  d'   d>t        j                   d
8       |j                  | j0                  d(   d?t        j                   d
8       |j                  | j0                  d+   d@t        j                   d
8       |j                  | j0                  d*   dAt        j                   d
8       |j                  |dt        j"                  t        j$                  z  d       |j                  |d
t        j"                  t        j$                  z  d       | jE                  t        jF                  | jH                  | j                         | jE                  t        jJ                  | jL                  | j0                  d          | jE                  t        jJ                  | jN                  | j0                  d           | jE                  t        jJ                  | jP                  | j0                  d'          |jS                  |       |jU                          |S )BNr  r  r  r  r   zEnter text:r   r  r  r   rn   r  ro   r6  rm   rp   r  r   r*  r/  r,  r7  r9  r;  zText effectsr   ztext backgroundr  r:  r  	highlighthighlightCtrlhighlightColorr   r   r4  r5  r6  highlightWidthrI  highlightWidthLabelztext borderr  r  r  borderWidthborderWidthLabelr  rH  TFr;   rh  r3   ri  r   r.   r   r   r   r   r   r   r   r   r   r   r#  r  )+r!   rD   r   r  r  r   r]  r  r&   r  r  r'   r   r  textCtrlr  r  r  r  r,  r@  r0  r  r  effectr   r   r%   r   r   r=  r>  r}   r  rC   EVT_ETC_LAYOUT_NEEDEDOnRefitr@  r  r  r  r^  r`  )	rG   r  r  r   rA  r  	textLabelr0  r  s	            rH   r  zTextDialog._textPanel(  s	   X"))2;K;KLe!F)4R[[) u&1V9:LM!!#r}}5u!M:JK	'biit}}V'<
 			!"*B*BRVV*KTU 	 	
 			MM))BFF2	 	 	
 	

5QRVVbii-?
J u&1_CU:UV!!#r{{3((aaaaHEdmm<JJ{#))	 	 	
 	JJz"))	 	 	
 	JJ'))	 	 	
 	JJ~&))	 	 	
 	JJ|$))	 	 	
 	JJ{#))	 	 	
 	$$Q'		-ABFFRYY4Fq	Q

5QRVVbii-?
J u&1^CT:TU!!#r{{3AA6(0biiq):';)
$% *:%BII)N%&'/biiq~(
O$ )9299(M$%(0biid&7&7QAq)
$% .8biiq'8.
)* %-biiq'7%
L! &6e		%JM"%-biid&7&7QBPQ&
M" +5biiq'8+
&'
 ==&.*0DMM,'==&&0KK()2248KK)*444==67 KK()2259KK)*44Z5HI=="*&,DMM(#=="f,KK(11$7KK()33Jt}}X?V4WXKK(11%8KK()33Jv4FG$%..s5x9P3Q/RS=="*&,DMM(#=="f,KK%..t4KK&00DMM(<S1TUKK%..u5KK&00G1DEM"++CdmmG6L0M,NOKK()))	 	 	
 	KK)*))	 	 	
 	KK())	 	 	
 	KK()))	 	 	
 	KK-.))	 	 	
 	KK()))	 	 	
 	KK%))	 	 	
 	KK&))	 	 	
 	KK*+))	 	 	
 	KK&))	 	 	
 			,1266BII3Ea	P

5QRVVbii-?
J		/77t}}U		"//4#4#4dkkBR6ST		"//4#3#3T[[5QR		"//4==$++l2KLv		rI   c           
         t        |t        j                  t        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd      }| j                  ||| j                         t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd      }	t        |t        j                  t        d	      
      | _        t        |t        j                  t        d      
      | _        t#        |t        j                  dddd      | _        t#        |t        j                  dddd      | _        | j$                  j)                  | j                  d          | j&                  j)                  | j                  d          |	j+                  | j                  dt        j,                  d       |	j+                  | j                   dt        j,                  d       |	j+                  | j$                  dt        j,                  d       |	j+                  | j&                  dt        j,                  d       |j+                  |	dt        j.                  t        j0                  z  d       |j+                  |dt        j2                  t        j.                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j                        }
t        j4                  dddd      }g }dD ]   }dD ]  }|j7                  |d z   |z           " t9        |t        j                  d!t        j:                  |d   "      g| _        | j<                  d   j)                  d#       |j+                  | j<                  d   dt        j>                  d       tA        dd$      D ]  }| j<                  j7                  t9        |t        j                  d!||   %             | j<                  d&   j)                  d#       |j+                  | j<                  d&   dt        j>                  d        | jC                  | j                  d'         j)                  d(       |jE                  d       |jE                  d       |jE                  d)       |
j+                  |dt        j.                  d       |j+                  |
d*t        jF                  t        j.                  z  d       |jE                  d       |jE                  d       |j+                  |dt        j,                  t        j0                  z  d       |j+                  |dt        j0                  t        j.                  z  d       t        |t        j                  dt        d+      z        }t        j                  |t        j                        }tI        |t        j                  t        d,      
      | _%        t#        |t        j                  ddd-d.      | _&        | j                  d/   rM| jL                  j)                  tO        | j                  d/                | jJ                  j)                  d(       n6| jL                  j)                  d       | jJ                  j)                  d#       |j+                  | jJ                  dt        j,                  t        jF                  z  t        j0                  z  d       |j+                  | jL                  dt        j,                  t        jF                  z  t        j0                  z  d       |j+                  |dt        j0                  t        j.                  z  d       |jQ                  |       |jS                          | jU                  t        jV                  | jX                  |jZ                  d0          | jU                  t        jV                  | jX                  |jZ                  d1          | jU                  t        j\                  | j^                  | jJ                         |S )2Nr  r2  r  r  r   rn   r   Offsetzhorizontal (pts):r   zvertical (pts):)r1  r   ir1  r   r  xoffsetyoffsetr   r   r   r   r   ro   r  r   z Reference pointrm   r  )upperr  r  )leftr  rightr2  r   )r   r   r   re  F	   r/  r   refTrp   r  zText rotationzrotate text (counterclockwise)r  )r   r4  r5  r6  r  r   r   )0r!   rD   r   r  r  r   r]  r  r&   r  r  r  r(  r  r'   	xoffLabel	yoffLabelr%   xoffCtrlyoffCtrlr   r  r  r  r  r  r,  r  r"   r  radior  r  r  r  r  r   rotCtrlrotValuer}   r^  r`  rC   r?  r  r   r@  r!  )rG   r  r  r   rA  r  r  box3sizerOrV  sizerRrI  r  rC  colr  s                   rH   r  zTextDialog._positionPanel  s   X"))2;K;KLe!J-8R[[)u&1Z=:PQ!!#r}}5AA6 	  dmmD "))6AhK;OP""45QQ7#EbiiqAT?UV#EbiiqAR?ST biihCR
 !biihCR
 	t}}Y78t}}Y78NNR-E-Ea 	 	
 	NNR-E-Ea 	 	
 	MMvB,D,DQ 	 	
 	MMvB,D,DQ 	 	
 	

=QRYY5GPQ
RR%?%?"))%KTU 	 	
 RYYfq9K7L.L
 ""34$$!!!!D	/ 	,C2 ,

39s?+,	, "))2R[[sSTvV

 	

1u%djjmPQRq! 	XAJJk%BIIRcRSfUVJJrN##E*MM$**R.QR__UVMW	X 	dmmE23<<TB  #  #  #

91
EV"--"))2KTUV##A&##A&		QR-E-E-NWX 	 	
 	

5QRVVbii-?
J u&1_CU:UV!!#r}}5biiq)I'J
 !2998Q
 =="MM""3t}}X'>#?@LL!!$'MM""1%LL!!%(		LL))BMM9BFFB	 	 	
 			MM))BMM9BFFB	 	 	
 	

5QRVVbii-?
Jv				"$$d&9&95>>);TU		"$$d&9&95>>';RS		"//4??DLLArI   c                 $    | j                          y r@   )r`  rK  s     rH   r  zTextDialog.OnRefitu  s    
rI   c                     | j                   j                         r| j                  j                          y | j                  j	                          y r@   )r  rP   r  r  r  rK  s     rH   r!  zTextDialog.OnRotationx  s2    <<  "MM  "MM!!#rI   c                 <   | j                   j                  d   j                         r{| j                  j	                         D ]   }|j                         j                          " | j                  j	                         D ]   }|j                         j                          " y | j                  j	                         D ]   }|j                         j                          " | j                  j	                         D ]   }|j                         j                          " y Nr   	r  r   rP   r  r>  rO   r  r  r  r  s      rH   r  zTextDialog.OnPositionType~      &&y1::<,,88: ,  "))+,,,88: -  "**,- ,,88: ,  "))+,,,88: -  "**,-rI   c                     | j                   d   j                         r.| j                   d   j                          | j                          y | j                   d   j	                          y r  r  rP   r  rB  r  rK  s     rH   r  zTextDialog.OnBackground  r  rI   c                    | j                   d   j                         rh| j                   d   j                          | j                   d   j                          | j                   d   j                          | j                          y | j                   d   j	                          | j                   d   j	                          | j                   d   j	                          y )Nr  r  r  r  r  rK  s     rH   r  zTextDialog.OnHighlight  s    ;;'002KK()002KK()002KK-.557KKMKK()113KK()113KK-.668rI   c                    | j                   d   j                         rh| j                   d   j                          | j                   d   j                          | j                   d   j                          | j                          y | j                   d   j	                          | j                   d   j	                          | j                   d   j	                          y )Nr  r  r  r  r  rK  s     rH   r  zTextDialog.OnBorder  s    ;;|$--/KK&--/KK&--/KK*+224KKMKK&..0KK&..0KK*+335rI   c                 .   | j                   j                         | j                  d<   | j                  d   s)t        j                  t        d      t        d             y| j                  j                  d   j                         | j                  d<   | j                  j                  d   j                         | j                  d<   | j                  j                  d	   j                         }t        |      | j                  d
<   | j                  d   j                         r6| j                  d   j                         }t        |      | j                  d<   nd| j                  d<   | j                  d   j                         r6| j                  d   j                         }t        |      | j                  d<   nd| j                  d<   | j                  d   j                         | j                  d<   | j                  d   j                         r6| j                  d   j                         }t        |      | j                  d<   nd| j                  d<   | j                  d   j                         | j                  d<   | j                  j                         | j                  d<   | j                  j                         | j                  d<   | j                  j                  d   j                         rd| j                  d<   | j                   j#                  | j                  j$                  d   j                               }|| j                  d<   | j                  j                  d    j                         r(| j                  j                  d    j                         }n| j                  d!   d"   }| j                  j                  d#   j                         r(| j                  j                  d#   j                         }n| j                  d!   d$   }| j                   j'                  t)        |      |d%&      }| j                   j'                  t)        |      |d%&      }||f| j                  d!<   t+        | j,                  | j.                     ||d| j0                  '      \  | j                  d(<   | j                  d)<   nid| j                  d<   | j                  j                  d*   j                         r5| j                  j                  d*   j                         | j                  d(<   n| j                  d(   | j                  d(<   | j                  j                  d+   j                         r5| j                  j                  d+   j                         | j                  d)<   n| j                  d)   | j                  d)<   t+        | j,                  | j.                     t)        | j                  d(         t)        | j                  d)         d| j0                  ,      | j                  d!<   | j2                  j                         r(| j4                  j                         | j                  d-<   nd | j                  d-<   | j6                  D ]0  }|j                         s|j9                         | j                  d.<   2 | j:                  | j,                  vr<t=        | j:                  | j0                  /      }	| j,                  j?                  |	       | j,                  | j:                     jA                  | j                         | j:                  | jB                  jD                  vr/| jB                  jD                  jG                  | j:                         y)0Nr  zNo text entered!ErrorFr/  r0  r7  r8  r;  r<  r  r  r  rH  r  r  r   r  r   r  r  rh  r  ri  r  r  r   Tr   r   r   r   r   r   r   ro   r   r   )r
  r   r&  r'  r  r  r  r  r  r  )$r  rP   r  rD   r  r   r  r0  r  r~  r>  r  r  r  r  r   r   r  r   r   r  r  r   r  r   r  r  r   r  r   r  rr  r  r   r  r  )
rG   r<  r  r   r  r  rV   r~   r   r  s
             rH   rB  zTextDialog.update  s    $ 6 6 8f}}V$MM!./7< !% 3 3J ? R R Tf$(NN$7$7$G$P$P$Rj!##K0::<!+E!2g ;;'(113%67AACJ*4Z*@DMM,'*0DMM,';;|$--/[[/99;F&0&8DMM(#&,DMM(#!%]!;!D!D!Fg;;'002$45??AI&0&;DMM(#&,DMM(#"&++.>"?"H"H"Jh $(==#9#9#;i #'==#9#9#;i  &&y1::<"&DMM$}}--""((5HHJH %-DMM&!!!**73<<>&&//8AACMM'*1-!!**73<<>&&//8AACMM'*1-%%E!HxPV%WA%%E!HxPV%WA%&TDMM'"<O  ,at=9DMM&!4==#9 #(DMM$!!**73<<>(,(:(:(C(CG(L(U(U(Wf%(,f(=f%!!**73<<>)-););)D)DW)M)V)V)Xg&)-w)?g&%8))$**5f-.g./ HH&DMM'" <<  "&*mm&<&<&>DMM(#&*DMM(#ZZ 	7E~~',}}e$	7 77$***TXX.D++D1!00?77$++...KK  ''0 rI   c                    | j                   d   dd \  }}| j                  j                  | j                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j                  j                  d   j                  d|z         | j                  j                  d	   j                  d|z         | j                   d
   | j                   d   }}| j                  j                  d   j                  t        | j                   d
                | j                  j                  d   j                  t        | j                   d                y%Update text coordinates, after movingr   Nrp   r   r   r   r   r   r   r&  r'  r  r  )
r  r   r  r  r   r  r   r   r   r   rG   rV   r~   r  rj  rh  s         rH   r  zTextDialog.updateDialog  sA    }}W%bq)1==))$$[1DDF
 MM!!F8!LMM!!F8!L##G,55gkB##G,55gkB}}V$dmmG&<1##G,55c$--:O6PQ##G,55c$--:P6QRrI   N)re   rf   rg   rA   r  r  r  r!  r  r  r  r  rB  r  ri   rI   rH   r  r    sA    )VUntl$
-5	9	6fPSrI   r  c                       e Zd ZdZ ed      f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d Zd Zd Zy)ImageDialogzWDialog for setting image properties.

    It's base dialog for North Arrow dialog.
    Imagec                 x   t         j                  | ||d||       d| _        | j                  A| j                  | j                     | _        | j                  |   j                         | _        nt               | _        | j                         | _        | j
                  j                         | _        | j                  j                  d      j                         }|d   |d   f| j                  d<   | j                  j                  d      }|s| j                  j                  d	      }|j                  | _        t        || j                  d   d
   | j                  d   d   d| j                        \  | j                  d<   | j                  d<   t        | t        j                   t        j"                        }|| _        | j'                  |      | _        | j+                  |      | _        | j/                  d        | j                  d   rS| j(                  j0                  d   j3                  t4        j6                  j9                  | j                  d                n6| j(                  j0                  d   j3                  | j;                                | j=                  d        | j?                  |       y )NzImage settingsrk  )imager  rq  rs  r   r  r  r   ro   Tr  r&  r'  r  epsfiler%  ) r   rA   r   r   r   imageObjr  	imageDictr  
_newObjectrp  r  r  r   r   rD   r   r  imagePanelName_imagePanel
imagePanelr  r  r  r  r   r  r  dirname_getImageDirectoryOnDirChangedrf  )	rG   r   r   r   r   r   r  r  r  s	            rH   rA   zImageDialog.__init__&  s1   " 	 	
 %77 ,,TWW5DM!--b1@@BDNgDG OO-DM!]]99;DN##99&APPRD&*6lDK&?DNN7#44U;""88CCVV
:MnnW%a(nnW%a(;
7vw 7 4BIIR]]K,**84!00:D!>>)$OO!!%(11y 9: OO!!%(11$2I2I2KL$XrI   c                 Z    t        | j                  | j                  | j                        S )z'Create corresponding instruction objectr  )r  r   r   r   rK   s    rH   r  zImageDialog._newObjectX  s    TWWd..DHH==rI   c           	      z   t        |t        j                  dt        j                        }|j	                  || j
                         t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }i |_        | j                  d   r-t        j                  j                  | j                  d         }n| j!                         }t#        |t        j                  t        d      t        d	      t        d
      || j$                        }||j                  d<   |j'                  |dt        j(                  d       t        j                  t        j*                        }t-        |t        j                        }	|	|j                  d<   |	j/                  t        j0                  | j2                         |j'                  |	dt        j(                  t        j4                  z  d       t        j                  t        j                        }
d| _        t9        | j6                   }t        j:                  |t        j                  t=        |            |j                  d<   |
j'                  |j                  d   dt        j(                  t        j>                  z  d       tA        |t        j                        |j                  d<   |
j'                  |j                  d   dt        jB                  d       |j'                  |
dt        j(                  d       |j'                  |dt        j(                  t        jD                  z  d       tA        |t        j                  t        d            }|j'                  |dt        jD                  d       |j'                  |dt        jD                  t        j(                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        jF                  dd      }tA        |t        j                  t        d            }tI        |t        j                  ddddtJ        jL                        |j                  d<   |j                  d   jO                  d        |j                  d   jQ                  d       | j                  d   rtS        | j                  d         }nd}|j                  d   jU                  |       |j'                  |d!t        jV                  "       |j'                  |j                  d   d#t        jV                  "       tA        |t        j                  t        d$            }tI        |t        j                  dd%ddtJ        jL                        |j                  d&<   |j                  d&   jO                  d        |j                  d&   jQ                  d       |j                  d&   jY                  t        d'             | j                  d&   r5|j                  d&   jU                  t[        | j                  d&                n|j                  d&   jU                  d       |j'                  |d(t        jV                  d)       |j'                  |j                  d&   d*t        jV                  "       | j]                  ||+       |j'                  |dt        j(                  t        jD                  z  d       |j'                  |dt        jD                  t        j(                  z  d       |j_                  |       |ja                          |S ),Nr)  r*  r  r  r  r   r  zChoose a directory:zChoose a directory with imagesrs  )r   r   rx  r{  ry  r|  changeCallbackr%  r   r  )r   r   r  ro   r2  )   r)  previewrn   sizeInform   zNote: only EPS format supportedzScale And Rotationr   r  r1  rJ  rK  r   rO  r   r   rB   r   Rotation angle (deg):r  r  $Counterclockwise rotation in degreesr   r   r   )r  r  )1r!   rD   r   r  r  r   r]  r  r&   r   r  r  r  r  r  r#  r$  r   r%  r  r  r  r   rC   EVT_LISTBOXOnImageSelectionChangedr  previewSizer*   StaticBitmapr   r  r'   r  r  r  r   rX  rY  r[  r\  r  r   r  rY  r}   _addConvergencer^  r`  )rG   r  r  r   rA  r  startDirr%  hSizer	imageListvSizerr  epsInfo	gridSizer
scaleLabelr   rotLabels                    rH   r!  zImageDialog._imagePanel\  s   		@P@P
 	e$*=*=>R[[) u&1W::MN!!#r{{3 >>)$wwt~~i'@AH..0Hyy-.:;{#,,
 !E		#!"))A	> R]]+5RYY7	'Fr~~t'C'CD

9RXX1Eb
Q R[[)%$**+!#		?SVCW!XI

KK	"qryy2997LUV 	 	
 #-Ebii"HJ

KK
#PQ 	 	
 	

6abii
B		&QRYY-?	JRYYa0Q.R
 			'abffQ	?

5QRVVbii-?
J
 RYYfq9M7N.N
 !!#r{{3OO3	u!H+N
(yy++ 
G 	G&&t,G&&q)>>'"$..12EEG%%e,jf23K3KLekk'*R=U=UVRYYa0G.H
 !*yy++!
H 	H''-H''*H((+Q)RS>>(#KK!**3t~~h/G+HIKK!**1-hF1I1IRSTekk(+b>V>VW5yA		)		BFF0B1	M

5QRVVbii-?
Jv		rI   c                    t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd      }| j                  ||| j                         | j                  t        j                  | j                  |j                   d	          | j                  t        j                  | j                  |j                   d
          |j#                  d       |j#                  d       |j%                  |dt        j&                  d       |j%                  |dt        j&                  t        j(                  z  d       |j+                  |       |j-                          |S Nr)  r*  r2  r  r  r   rn   r   r   r   r   ro   r  )r!   rD   r   r  r  r   r]  r  r&   r  r  r(  r  rC   r?  r  r   r  r  r  r  r^  r`  r  s          rH   r  zImageDialog._positionPanel  \   		@P@P
 	e!J-8R[[) u&1Z=:PQ!!#r{{3AA6  dnnE		"$$d&9&95>>);TU		"$$d&9&95>>';RS##A&##A&		,1266!	D

5QRVVbii-?
Jv		rI   c                 J   | j                   j                  d   j                         }	 t        j                  |      }g }	 || j                   j                  d   _        |D ]G  }t        j                  j                  |      d   j                         dk(  s7|j                  |       I |j                          | j                   j                  d   j                  |       | j                  d   rUt        j                  j                  | j                  d         }| j                   j                  d   j!                  |       n*|r(| j                   j                  d   j#                  d       | j%                  d       y# t
        $ r g }Y Sw xY w# t        $ r Y Bw xY w)zImage directory changedr%  ro   .epsr  r  r   N)r"  r  rP   r  r  OSErrorr|  AttributeErrorr  splitextr  r  sortr;  r  basenamer   r  r0  )rG   rc   r  filesr6  r]  s         rH   r%  zImageDialog.OnDirChanged  s_   $$U+446	JJt$E 		:>DOO!!%(7  	'Dww%a(..0F:  &	' 	f%..y9>>)$77##DNN9$=>DOO!!&)<<TBOO!!&)66q9$$T*)  	E	  		s#   F F FF	F"!F"c                 <   | j                   j                  d   j                         r{| j                  j	                         D ]   }|j                         j                          " | j                  j	                         D ]   }|j                         j                          " y | j                  j	                         D ]   }|j                         j                          " | j                  j	                         D ]   }|j                         j                          " y r
  r  r  s      rH   r  zImageDialog.OnPositionType  r  rI   c                 *    t        j                         S )zDefault image directory)r  getcwdrK   s    rH   r$  zImageDialog._getImageDirectory"  s    yy{rI   c                      y r@   ri   )rG   r  r  s      rH   r3  zImageDialog._addConvergence&  s    rI   c                 h   | j                   j                  d   syt        s| j                  t	        d             y| j                   j                  d   j                         }|s| j                          y| j                   j                  d   j                         }t        j                  j                  ||      }t        j                  j                  |      syt        j                  j                  |      d   j                         dk(  re	 t        j                  |      }t!        |      }| j'                  |       | j)                  |      }|j+                         }| j-                  |       yy# t"        $ r2}t%        t	        d      |z         | j                          Y d}~yd}~ww xY w)	z%Image selected, show preview and sizer%  NzPIL
missingr  ro   r@  zUnable to read file %sr  )r"  r  havePILImageDrawWarningTextr   r  ClearPreviewrP   r  r  ru  r  rC  r  PILImageopenr   IOErrorr   SetSizeInfoLabelScaleToPreviewConvertToBitmap
DrawBitmap)	rG   rc   	imageNamebasePathr]  pImgr  rj  rq  s	            rH   r0  z#ImageDialog.OnImageSelectionChanged)  s]   $$
   >!23OO))&1DDF	??((/88:ww||Hi0ww~~d#77D!!$**,6}}T*'-
 !!#&%%c*C((*FOOF#   q!9:TAB!!#s    E6 6	F1?(F,,F1c                 l   |j                         }|j                         }|| j                  d   k  r|| j                  d   k  r|S ||kD  r%| j                  d   }| j                  d   |z  |z  }n$| j                  d   }| j                  d   |z  |z  }|j                  ||t        j
                        S )zScale image to preview sizer   ro   )GetWidth	GetHeightr1  ScalerD   IMAGE_QUALITY_HIGH)rG   r  rk  rE  newWnewHs         rH   rS  zImageDialog.ScaleToPreviewN  s    LLNMMO  ##T-=-=a-@(@Jq5##A&D##A&*a/D##A&D##A&*a/DyytR%:%:;;rI   c           	      F   t        | j                   }t        j                         }|j	                  |       |j                  t        j                  t        j                  ddd                   |j                          |j                  |      }| j                  d   dz  |d   dz  z
  }| j                  d   dz  |d   dz  z
  }|j                  |||       | j                  j                  d   j                  |       |j	                  t        j                         y)zDraw text on preview windowr   r   rp   ro   r*  N)r   r1  rD   MemoryDCSelectObjectr   r   r   Clearr)  r{   r"  r  	SetBitmap
NullBitmap)rG   r9  bufferr   r}  posXposYs          rH   rM  zImageDialog.DrawWarningText\  s    d../[[]

BHHRYYsC567

!!'*"Q&Q6"Q&Q6
GT4(i(226:
&rI   c                 &   |j                         | j                  d   k  r.|j                         | j                  d   k  rt        | j                   }t	        j
                         }|j                  |       |j                  |j                                |j                          | j                  d   dz  |j                         dz  z
  }| j                  d   dz  |j                         dz  z
  }|j                  |||       | j                  j                  d   j                  |       |j                  t        j                         n(| j                  j                  d   j                  |       | j                  j                          y)z3Draw bitmap, center it if smaller than preview sizer   ro   rp   r*  N)rZ  r1  r[  r   rD   ra  rb  r   GetBrushrc  rU  r"  r  rd  re  r  )rG   rq  rf  r   rg  rh  s         rH   rU  zImageDialog.DrawBitmapj  s4    OO!1!1!!44  "d&6&6q&99 $"2"23FBOOF#KK&HHJ##A&!+foo.?1.DDD##A&!+f.>.>.@A.EEDMM&$-OO!!),66v>OOBMM*OO!!),66v>!rI   c                    | j                   j                  d   j                  t        d      |j	                         |j                         dz         | j                   j                  d   j                         j                          y)zUpdate image size labelr+  z size: %(width)s x %(height)s pts)r   r   N)r"  r  r  r   rZ  r[  GetContainingSizerr_  )rG   r  s     rH   rR  zImageDialog.SetSizeInfoLabel~  sj    j)2201(EOO4EFG	
 	j)<<>EEGrI   c                    t        | j                   }t        j                         }|j	                  |       |j                  t        j                         |j                          |j	                  t        j                         t        j                  |t        j                        }|j                  |       | j                  j                  d   j                  |       y)zClear preview windowr*  N)r   r1  rD   ra  rb  r   WHITE_BRUSHrc  re  r3  WHITESetMaskr"  r  rd  )rG   rf  r   rA  s       rH   rN  zImageDialog.ClearPreview  s    d../[[]

BNN#


&wwvrxx(ti(226:rI   c                    | j                   j                  d   j                         }| j                   j                  d   j                         }|st	        | t        d             yt        j                  j                  ||      | j                  d<   | j                  j                  d   j                         rd| j                  d	<   | j                  j                  | j                  j                  d
   j                               }|| j                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   d   }| j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   d   }| j                  j                  t!        |      |d      }| j                  j                  t!        |      |d      }||f| j                  d<   nEd| j                  d	<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   | j                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   | j                  d<   t#        | j$                  | j&                     t!        | j                  d         t!        | j                  d         d| j(                        \  }}| j                   j                  d   j                         }|dk(  rd | j                  d<   n|| j                  d<   | j                   j                  d   j                         | j                  d<   | j*                  j-                  | j                  d         \  }	}
| j                  d   r(t/        |	|
| j                  d         | j                  d<   n|	|
f| j                  d<   | j                  j                  | j                  d   d   dd      }	| j                  j                  | j                  d   d   dd      }
t1        |||	| j                  d   z  |
| j                  d   z        | j                  d<   | j2                  | j$                  vr+| j5                         }| j$                  j7                  |       | j$                  | j2                     j9                  | j                         | j2                  | j:                  j<                  vr/| j:                  j<                  j?                  | j2                         y)Nr  r%  zNo image selected.)r   r  Fr  r   Tr   r   r   r   r   r   r   ro   r   r   r  r&  r  r'  r  r  r   r   r,  rg  r   ) r"  r  r  rP   r   r   r  r  ru  r  r  r   r   r  r   r   r  r  r   r  r   r  GetImageOrigSizeBBoxAfterRotationrj  r   r  rr  r  r   r  r  )rG   rN  rW  r  rV   r~   rj  rh  rotrk  rE  r  s               rH   rB  zImageDialog.update  s   ??((0CCE??((/88:D!,@*AB$&GGLL8$Dy! &&y1::<#'DNN4 }}--""((5HHJH &.DNN6"!!**73<<>&&//8AACNN7+A.!!**73<<>&&//8AACNN7+A.%%E!HxPV%WA%%E!HxPV%WA&'dDNN7# $)DNN4 !!**73<<>&&//8AAC)-)?v&!!**73<<>&&//8AAC*...*Aw'&))$**5v./w/0 HHDAq oo##H-668!8'+DNN8$'*DNN8$ #'//"7"7"@"I"I"Kw }}--dnnY.GH1>>(#%6q!T^^H=U%VDNN6"%&TDNN6"MM!!..(+gf " 
 MM!!..(+gf " 
 "(dnnW--t~~g..	"
v 77$***OO%E++E2!00@77$++...KK  ''0rI   c                    | j                   d   dd \  }}| j                  j                  | j                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j                  j                  d   j                  d|z         | j                  j                  d	   j                  d|z         | j                   d
   | j                   d   }}| j                  j                  d   j                  t        | j                   d
                | j                  j                  d   j                  t        | j                   d                yr  )
r  r   r  r  r   r  r   r   r   r   r  s         rH   r  zImageDialog.updateDialog  A    ~~g&r*1==))$$[1DDF
 MM!!F8!LMM!!F8!L##G,55gkB##G,55gkB~~f%t~~g'>1##G,55c$..:P6QR##G,55c$..:Q6RSrI   N)re   rf   rg   rh   r   rA   r  r!  r  r%  r  r$  r3  r0  rS  rM  rU  rR  rN  rB  r  ri   rI   rH   r  r     sj    
 BC7 0d>@D:+6
-#J<'"(H
;ZxTrI   r  c                   *    e Zd Zd Zd Zd Zd Zd Zy)NorthArrowDialogc           	          t         j                  | |||t        d      |       d| _        | j	                  t        d             y )NzNorth Arrow)r   r   r   r   r   )
northArrowzNorth Arrow settings)r  rA   r   r   r  r  s        rH   rA   zNorthArrowDialog.__init__   sG    ]+ 	 	
 *a./0rI   c                 Z    t        | j                  | j                  | j                        S )Nr  )
NorthArrowr   r   r   rK   s    rH   r  zNorthArrowDialog._newObject  s    $''4#3#3BBrI   c                 p    t        j                  d      }t         j                  j                  |ddd      S )Nr  r  r  decorations)r  r  r  ru  )rG   r$  s     rH   r$  z#NorthArrowDialog._getImageDirectory  s)    ))I&ww||GUG]CCrI   c                 &   t        |t        j                  t        d            }|j	                  |dt        j
                  t        j                  z         |j                  t        j                  | j                         ||j                  d<   y )NzCompute convergencer   r   r,  convergence)r   rD   r   r   r  r  r  rC   rX  OnConvergencer  )rG   r  r  r  s       rH   r3  z NorthArrowDialog._addConvergence  sm    EbiiqAV?WXV"*B*BRYY*N 	 	
 	(:(:;%0M"rI   c                 V   t        ddd| j                        }|rt        |j                         j	                  d      d         }|dk  r2| j
                  j                  d   j                  t        |             y | j
                  j                  d   j                  d	|z
         y y )
Nzg.regionTnug)rv  r   r   =ro   r   r  r  )	r   r   r  r  r  r"  r  r   abs)rG   rc   retr  s       rH   r  zNorthArrowDialog.OnConvergence  s    $eJ		 1 1# 6q 9:KQ%%h/88[9IJ%%h/88{9JK rI   N)re   rf   rg   rA   r  r$  r3  r  ri   rI   rH   rx  rx    s    1CD1LrI   rx  c                   L    e Zd ZdZd ed      fdZd Zd Zd Zd Z	d	 Z
d
 Zy)PointDialogz$Dialog for setting point properties.NPointc                    t         j                  | ||d||       d| _        | j                  A| j                  | j                     | _        | j                  |   j                         | _        nct               | _        t        | j                  | j                        | _        | j
                  j                         | _        || j                  d<   | j
                  j                  | _        | j                  j                  d      }|s| j                  j                  d      }|j                  | _        t        || j                  d   d   | j                  d   d	   d
| j                        \  | j                  d<   | j                  d<   t!        | t"        j$                  t"        j&                        }|| _        | j+                  |      | _        | j/                  |      | _        | j3                  d        | j5                  |       y )NzPoint settingsrk  )r,  r  r   r  r  r   ro   Tr  r&  r'  r  )r   rA   r   r   r   pointObjr  	pointDictr  r  r   defaultInstructiondefaultDictrp  r  r  r   rD   r   r  pointPanelName_pointPanel
pointPanelr  r  r  rf  )	rG   r   r   r   r   coordinatesr  mapObjr  s	            rH   rA   zPointDialog.__init__)  s    	" 	 	
 %77 ,,TWW5DM!--b1@@BDNgDG!$''txx8DM!]]99;DN&1DNN7#==;;!!77>%%;;IFFYY
:MnnW%a(nnW%a(;
7vw 7 4BIIR]]K,**84!00:D!XrI   c           	         t        |t        j                  dt        j                        }|j	                  || j
                         t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd      }|j                  t        |t        j                  t        d	            d
t        j                         t        |t        j                  | j                   d         | _        |j                  | j"                  dt        j                         t        j$                  t&        j(                  j+                  t,        j.                  | j                   d         dz         }t1        |t        j                  |      | _        | j2                  j5                  t        j6                  | j8                         |j                  | j2                  dt        j                         t        |t        j                  t        d            | _        |j                  | j:                  ddt        j                         |j=                  d       |j                  |dt        j>                  t        j@                  z  d       |j                  |dt        j@                  t        j>                  z  d       t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd      }t        |t        j                  t        d            }tC        |t        j                        | _"        tG        |t        j                  t        d            | _$        | j                   d   dk7  rM| jH                  jK                  d       | jD                  jM                  tO        | j                   d                nL| jH                  jK                  d        | jD                  jM                  tO        | jP                  d                |j                  |d
t        j                         |j                  | jD                  dt        j                         |j                  | jH                  dt        j                         t        |t        j                  t        d!            }	tC        |t        j                        | _)        tG        |t        j                  t        d            | _*        | j                   d"   dk7  rM| jT                  jK                  d       | jR                  jM                  tO        | j                   d"                nL| jT                  jK                  d        | jR                  jM                  tO        | jP                  d"                |j                  |	dt        j                         |j                  | jR                  d#t        j                         |j                  | jT                  dt        j                         |j                  |dt        j>                  t        j@                  z  d       |j                  |dt        j@                  t        j>                  z  d       t        |t        j                  dt        d$      z        }t        j                  |t        j                        }t        j                  dd      }t        |t        j                  t        d%            }
tW        |t        j                  | jX                  &      | _-        | jZ                  j]                  t        d'             | jZ                  jK                  | j                   d(          |j                  |
d
t        j                         |j                  | jZ                  dt        j                         t        |t        j                  t        d)            }t_        |t        j                  d*d+ddt`        jb                  ,      | _2        | jd                  jg                  d-       | jd                  ji                  d       | jd                  j]                  t        d.             | jd                  jK                  tk        | j                   d/                |j                  |dt        j                  d0       |j                  | jd                  d#t        j                         |j                  |dt        j>                  t        j@                  z  d       |j                  |dt        j@                  t        j>                  z  d       |jm                  |       |jo                          |S )1Nr)  r*  r  r  Symbolr   rn   r   zSelect symbol:r   r,  r   r   ro  rp  r  zKNote: Selected symbol is not displayed
in draft mode (only in preview mode)r   r   )r   r   rB   ro   r  r   ColorOutline color:r:  transparentr   r<  rH  FTFill color:rR  r   zSize and Rotationz
Size (pt):)r   r   zSymbol size in pointsr   r-  ir  rK  rO  r.  r  r   )8r!   rD   r   r  r  r  r]  r  r&   r   r  r  r  r  r'   r  r  symbolLabelr  r  r  ru  r   r  r   r  rC   rX  r  	noteLabelr  r  r  r   outlineColorCtrlr   outlineTranspCtrlr   r=  r>  r  fillColorCtrlfillTranspCtrlr%   r   sizeCtrlrY  r   rX  rY  r  r[  r\  r  r^  r`  )rG   r  r  r   rA  r  r9  rq  outlineLabel	fillLabel	sizeLabelr;  s               rH   r  zPointDialog._pointPanelU  s   		@P@P
 	e$*=*=>R[[) u&1X;:NO!!#r}}5OO3	e		;K9LM)) 	 	
 &RYYdnnX.F
 	d&&F9Q9QRGGLL**DNN8,DEN
 )299VLr}}d.D.DEd''V":R:RS#yy7
 	NNV":R:R 	 	
 	  #		)		BFF0B1	M

5QRVVbii-?
J u&1W::MN!!#r{{3OO3	!299AFVDWX 0299 E!)%BIIQ}EU!V>>'"f,""++E2!!++Jt~~g7N,OP""++D1!!++Jt7G7G7P,QRlR5M5MNd++b>V>VWd,,&r?W?WXe		=AQR	-e		B&u!MBRS>>(#v-((/((DNN84L)MN((.((D4D4DX4N)OPiV"2J2JKd((f2;S;STd))vB<T<TU		)		BFF0B1	M

5QRVVbii-?
J RYYfq9L7M.M
 !!#r{{3OO3	e		<Q	 2994;L;LM  #:!;<t~~f56iV"2J2JKdmmb6N6NO RYYa0G.H
 !yy++
 	t$q!"H IJeDNN8$<=>hF1I1IRSTdllR5M5MN		)		BFF0B1	M

5QRVVbii-?
Jv		rI   c                    t        |t        j                  dt        j                        }|j	                  |t        d             t        j                  t        j                        }t        |t        j                  dt        d      z        }t        j                  |t        j                        }t        j                  dd      }| j                  ||| j                         | j                  t        j                  | j                  |j                   d	          | j                  t        j                  | j                  |j                   d
          |j#                  d       |j#                  d       |j%                  |dt        j&                  d       |j%                  |dt        j&                  t        j(                  z  d       |j+                  |       |j-                          |S r=  )r!   rD   r   r  r  r   r]  r  r&   r  r  r(  r  rC   r?  r  r   r  r  r  r  r^  r`  r  s          rH   r  zPointDialog._positionPanel  r>  rI   c                 <   | j                   j                  d   j                         r{| j                  j	                         D ]   }|j                         j                          " | j                  j	                         D ]   }|j                         j                          " y | j                  j	                         D ]   }|j                         j                          " | j                  j	                         D ]   }|j                         j                          " y r
  r  r  s      rH   r  zPointDialog.OnPositionType   r  rI   c                    t        | t        j                  | j                  j	                               }|j                         t        j                  k(  rl|j                         }|j                         }| j                  j                  t        j                  |dz                | j                  j                  |       |j                          y r  )r   r   r  r  r  r  rD   rU  r  r  r  r  r  r  rO  r  s        rH   r  zPointDialog.OnSymbolSelection  s     ((**335

 ==?bhh&++-C,,.D,,RYYsV|-DE%%d+rI   c                 
   | j                   j                         | j                  d<   | j                  j                  d   j                         rd| j                  d<   | j                  j                  | j                  j                  d   j                               }|| j                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   d	   }| j                  j                  d
   j                         r(| j                  j                  d
   j                         }n| j                  d   d   }| j                  j                  t        |      |d      }| j                  j                  t        |      |d      }||f| j                  d<   nEd| j                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   | j                  d<   | j                  j                  d   j                         r(| j                  j                  d   j                         }n| j                  d   | j                  d<   t        | j                  | j                     t        | j                  d         t        | j                  d         d| j                        \  }}| j                   j                         | j                  d<   | j"                  j                         | j                  d<   | j                  j                  | j                  d   dd      x}}| j$                  j                         rd| j                  d<   n0t'        | j(                  j+                               | j                  d<   | j,                  j                         rd| j                  d<   n0t'        | j.                  j+                               | j                  d<   t1        ||dz  z
  ||dz  z
  ||      | j                  d<   | j2                  | j                  vr<t5        | j2                  | j                        }| j                  j7                  |       | j                  | j2                     j9                  | j                         | j2                  | j:                  j<                  vr/| j:                  j<                  j?                  | j2                         y)Nr   r   Tr   r   r   r   r   r   r   ro   r   r   Fr  r&  r  r'  r  r  r   r,  rH  r<  rR  rp   rg  r   r  ) r  r  r  r  r   rP   r   r  r   r  r   r  r  r   r  r   r  r  r  r>  r  r~  r  r  rj  r   r  rr  r  r   r  r  )	rG   r  rV   r~   rj  rh  rk  rE  r,  s	            rH   rB  zPointDialog.update  s+   #'#3#3#<#<#>x  &&y1::<#'DNN4 }}--""((5HHJH &.DNN6"!!**73<<>&&//8AACNN7+A.!!**73<<>&&//8AACNN7+A.%%E!HxPV%WA%%E!HxPV%WA&'dDNN7# $)DNN4 !!**73<<>&&//8AAC)-)?v&!!**73<<>&&//8AAC*...*Aw'&))$**5v./w/0 HHDAq $(<<#8#8#:x  "&!7!7!9v%%..(76 & 
 	
A
 !!**,&,DNN7#&01F1F1P1P1R&SDNN7# '')'-DNN8$'1$2D2D2N2N2P'QDNN8$!'!a!e)q1q5yRS!Tv77$***$''txx0E++E2!00@77$++...KK  ''0rI   c                    | j                   d   dd \  }}| j                  j                  | j                  j                  d   j                               }| j                  j                  |d|      }| j                  j                  |d|      }| j                  j                  d   j                  d|z         | j                  j                  d	   j                  d|z         | j                   d
   | j                   d   }}| j                  j                  d   j                  t        | j                   d
                | j                  j                  d   j                  t        | j                   d                yr  )
r  r   r  r  r   r  r   r   r   r   r  s         rH   r  zPointDialog.updateDialogi  rv  rI   )re   rf   rg   rh   r   rA   r  r  r  r  rB  r  ri   rI   rH   r  r  &  s9    . 6:!G**XL\:
-M^TrI   r  c                   &    e Zd ZddZd Zd Zd Zy)RectangleDialogNc                    |dk(  rt        d      }nt        d      }t        j                  | |||||       |f| _        | j                  >| j
                  | j                     | _        | j                  j                         | _        nt               | _        |dk(  r't        | j                  | j                        | _        n&t        | j                  | j                        | _        | j                  j                         | _        t        |d   |d         | j                  d	<   || j                  d
<   | j                  j                  | _        | j!                         | _        | j%                  | j"                         y)zZ

        :param coordinates: begin and end point coordinate (wx.Point, wx.Point)
        	rectanglezRectangle settingszLine settingsrk  Nr  r   ro   r   r   )r   r   rA   r   r   r   rectObjr  rectDictr  	Rectangler   LineRect2DPPr  r  
_rectPanelr  rf  )rG   r   r   r   r   r  r  r   s           rH   rA   zRectangleDialog.__init__{  s,   
 ;*+Eo&EBehC 	 	
  '77++DGG4DL LL779DMgDG{"(dhh?#DGG: LL779DM$,[^[^$LDMM&!%0DMM'"<<::__&
TZZ rI   c           	         t        | t        j                  t        j                        }t        j                  t        j
                        }t        |t        j                  dt        d      z        }t        j                  |t        j
                        }t        j                  dd      }t        |t        j                  t        d            }t        |t        j                        | _        t        |t        j                  t        d	      
      | _        | j                  d   dk7  rM| j                  j!                  d       | j                  j#                  t%        | j                  d                nL| j                  j!                  d       | j                  j#                  t%        | j&                  d                | j(                  dk(  r| j                  j+                          |j-                  |dt        j.                         |j-                  | j                  dt        j.                         |j-                  | j                  dt        j.                         | j(                  dk(  rt        |t        j                  t        d            }t        |t        j                        | _        t        |t        j                  t        d	      
      | _        | j                  d   dk7  rM| j2                  j!                  d       | j0                  j#                  t%        | j                  d                nD| j2                  j!                  d       | j0                  j#                  t        j4                         |j-                  |dt        j.                         |j-                  | j0                  dt        j.                         |j-                  | j2                  dt        j.                         |j-                  |dt        j6                  t        j8                  z  d       |j-                  |dt        j8                  t        j6                  z  d       t        j                  dd      }t        |t        j                  dt        d      z        }t        j                  |t        j
                        }t        |t        j                  t        d            }t;        |t        j                  ddddt<        j>                         | _         | j@                  jC                  d!       | j@                  jE                  d       | j@                  jG                  t        d"             | j@                  j!                  tI        | j                  d#                |j-                  |dt        j.                         |j-                  | j@                  dt        j.                         |j-                  |dt        j6                  t        j8                  z  d       |j-                  |dt        j8                  t        j6                  z  d       |jK                  |       |S )$Nr  r  r  r   rn   r   r  r:  r  r   r<  rH  FT)r  r   r,  r   r  r  r  rR  r   r   r   ro   r  r   r  zLine width:r1  rK  rO  zLine width in pointsr   )&r!   rD   r   r  r]  r  r&   r   r  r  r'   r   r  r   r  r  r   r=  r>  r  r   r=  r  r  r  r  ro  r  r  r   rX  rY  r7  r[  r\  rY  r  r^  )	rG   r  r   rA  r  r9  r  r  
widthLabels	            rH   r  zRectangleDialog._rectPanel  sr   Tbiir7G7GHR[[) u&1W::MN!!#r{{3OO3	!299AFVDWX 0299 E!)%BIIQ}EU!V==!V+""++E2!!++Jt}}W7M,NO""++D1!!++Jt7G7G7P,QR ??i'""'')lR5M5MNd++b>V>VWd,,&r?W?WX ??n,"%BIIQ}EUVI!1%BII!FD"*5RYYaFV"WD}}X&&0##,,U3"",,Zh8O-PQ##,,T2"",,RXX6MM)b6N6NMOMM$,,&r?W?WMXMM##b6N6N   			)		BFF0B1	M

5QRVVbii-?
JOO3	 u&1\?:RS!!#r{{3u!MBRS
"yy++
 	  &  #!!!$:";<dmmG&< =>jf23K3KLdnn&r7O7OP		)		BFF0B1	M

5QRVVbii-?
JvrI   c                    | j                   j                  d      }|s| j                   j                  d      }|j                  | _        | j                  d   d   }| j                  d   d   }t        ||d   |d   d| j                        \  | j                  d<   | j                  d	<   t        ||d   |d   d| j                        \  | j                  d
<   | j                  d<   | j                  j                         | j                  d<   | j                  j                         rd| j                  d<   n0t        | j                  j                               | j                  d<   | j                  dk(  rZ| j                  j                         rd| j                  d<   n0t        | j                  j                               | j                  d<   | j                  | j                   vrm| j                  dk(  r"t!        | j                  | j                        }n!t#        | j                  | j                        }| j                   j%                  |       | j                   | j                     j'                  | j                         | j                  | j(                  j*                  vr/| j(                  j*                  j-                  | j                         | j/                          y)Nr  r  r   r   ro   Tr  east1north1east2north2r   rH  r<  r  rR  r  )r   rp  r   r  r  r  r   r7  rP   r  r>  r  r~  r   r  r  r  r  rr  r  r   r  r  r  )rG   r	  point1point2r   s        rH   rB  zRectangleDialog.update  sB   ##99%@''==iHH[[
w'*w'*:MfQiDdhh;
7gh 7 ;NfQiDdhh;
7gh 7 "&!8!8!:g !!**,%+DMM'"%/0E0E0O0O0Q%RDMM'" ??n,""++-*0h'*4T5G5G5Q5Q5S*Th'77$***.0 dhh7DGG2++D1!00?77$++...KK  ''0rI   c                      y)r  Nri   rK   s    rH   r  zRectangleDialog.updateDialog  r  rI   )r  N)re   rf   rg   rA   r  rB  r  ri   rI   rH   r  r  z  s     !DPd+ZrI   r  c                       e Zd Zd Zd Zd Zy)LabelsDialogc                    t         j                  | ||t        d      ||       d| _        | j                  | j
                  | j                     | _        n5t               | _        t        | j                  | j                        | _        | j                  j                         | _        | j                         | _        | j                  | j                         y )NzVector labelsrk  )r  r  )r   rA   r   r   r   r   r  r  Labelsr   r  
labelsDict_labelPanelr  rf  r  s        rH   rA   zLabelsDialog.__init__"  s    O$ 	 	
 &77**4773DKgDG dhh7DK++446%%'
TZZ rI   c                 T   t        | t        j                  t        j                        }t        j                  t        j
                        }t        |t        j                  dt        d      z        }t        j                  |t        j
                        }t        |ddd      | _
        | j                  j                  d	j                  | j                  d
                | j                  j                          |j                  | j                  dt        j                   t        j"                  z  d       t%        |t        j                  t        d            }|j'                  t        j(                  j+                  t        j,                               |j                  |dt        j                   t        j.                  z  t        j0                  z  d       |j                  |dt        j                   t        j"                  z  d       |j3                  |       |S )Nr  r  z7Vector label files created beforehand by v.label moduler   Tr   F)r   r  r  fullyQualified,r  ro   rn   r  z$You can select multiple label files.r   r   )r!   rD   r   r  r]  r  r&   r   r  r
   r  r   ru  r  r  r  r  r  r'   SetForegroundColourSystemSettingsr~  SYS_COLOUR_GRAYTEXTr  r  r^  )rG   r  r   rA  r  helpTexts         rH   r  zLabelsDialog._labelPanel6  sz   Tbiir7G7GHR[[)yy1VWW

 !!#r{{34ge
 	SXXdooh&?@A		$++!"))bff2DQ	Obiiq)O'P
 	$$''(>(>?	
 			(qryy277/BRXX/MVW	X

5QRYY-?
JvrI   c                    | j                   j                         }|sg | j                  d<   n|j                  d      | j                  d<   | j                  | j
                  vr<t        | j                  | j                        }| j
                  j                  |       | j
                  | j                     j                  | j                         y)Nr  r  r  T)
r  rP   r  r  r   r   r  r   rr  r  )rG   r   r  s      rH   rB  zLabelsDialog.updateU  s    $$&(*DOOH%(-C(8DOOH%77$***DGG2F++F3!00ArI   N)re   rf   rg   rA   r  rB  ri   rI   rH   r  r  !  s    !(>rI   r  )Wrh   r  rQ   copyr   rD   wx.lib.agw.floatspinlibagw	floatspinrX  wx.lib.mixins.listctrlr   corer   r   r   r   grass.scriptscriptrn  
core.utilsr   dbmgr.vinfor	   gui_core.gselectr
   	core.gcmdr   r   r   gui_core.dialogsr   gui_core.wrapr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   psmap.utilspsmap.instructionsPSMAP_COLORSr>   rk   r   r   ri  r  r  r  r  r  r  r  r  r  r  r  r  rx  r  r  r  ri   rI   rH   <module>r     s  "H 
   	 ! ! 9 +  ( $ # 2 2 )       >   (') 'TB) BJ.H02H .$w& wt	Pk Pfi8 i8Xz
E z
zD% DNC% CL
+; +j {  FWV WVt$l2; l2^#Z;K Z;zD;[ D;NaS aSH\T+ \T~$L{ $LNQT+ QTh
dk dN@; @rI   