
    ը	f6                         d Z ddlZddlmc mZ ddlmZ  G d d      Z G d de      Z	 G d d	e      Z
 G d
 de      Z G d de      Z G d de      Z G d de      Z G d dej                        Zy)a  
@package mapdisp.properties

@brief Classes for map display properties management

Classes:
 - properties::PropertyItem
 - properties::ChBRender
 - properties::ChBShowRegion
 - properties::ChBAlignExtent
 - properties::ChBResolution
 - properties::ChBProjection
 - properties::RBShowInStatusbar
 - properties::MapDisplayPropertiesDialog

(C) 2021 by the GRASS Development Team

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

@author Vaclav Petras <wenzeslaus gmail.com>
@author Anna Kratochvilova <kratochanna gmail.com>
@author Linda Kladivova <lindakladivova gmail.com>
    N)Buttonc                   t    e Zd ZdZd Zed        Zej                  d        Zd Zd Z	d Z
d Zd	 Zd
 Zd Zy)PropertyItemzGBase class for Map Display properties widgets that use property signalsc                     || _         y N)_properties)selfmapWindowPropertiess     3/usr/lib/grass83/gui/wxpython/mapdisp/properties.py__init__zPropertyItem.__init__"   s
    .    c                      y r    r	   s    r   mapWindowPropertyzPropertyItem.mapWindowProperty%       r   c                      y r   r   r	   values     r   r   zPropertyItem.mapWindowProperty)   r   r   c                      y)z(Returns signal from MapWindowProperties.Nr   r   s    r   mapWindowPropertyChangedz%PropertyItem.mapWindowPropertyChanged-   r   r   c                 :    | j                   j                  |       y r   )widgetSetValuer   s     r   	_setValuezPropertyItem._setValue1   s    U#r   c                 6    | j                   j                         S r   )r   GetValuer   s    r   r   zPropertyItem.GetValue4   s    {{##%%r   c                     | j                   S )zUReturns underlying widget.

        :return: widget or None if doesn't exist
        )r   r   s    r   	GetWidgetzPropertyItem.GetWidget7   s    
 {{r   c                 V    | j                         j                  | j                         y r   )r   connectr   r   s    r   _connectzPropertyItem._connect>   s    %%'//?r   c                 V    | j                         j                  | j                         y r   )r   
disconnectr   r   s    r   _disconnectzPropertyItem._disconnectA   s    %%'224>>Br   c                 n    | j                          | j                         | _        | j                          y r   )r%   r   r   r"   )r	   events     r   	_onTogglezPropertyItem._onToggleD   s%    !%r   N)__name__
__module____qualname____doc__r   propertyr   setterr   r   r   r   r"   r%   r(   r   r   r   r   r      s]    Q/    $&@Cr   r   c                   P    e Zd ZdZd Zed        Zej                  d        Zd Zy)	ChBRenderz.Checkbox to enable and disable auto-rendering.c                    t         j                  | |       d| _        t        j                  |t        j
                  t        d            | _        | j                  j                  | j                         | j                  j                  t        j                  t        d                   | j                  j                  t        j                  | j                         | j                          y )NrenderzEnable auto-renderingparentidlabelzEnable/disable auto-renderingr   r   namewxCheckBoxID_ANY_r   r   r   
SetToolTipToolTipBindEVT_CHECKBOXr(   r"   r	   r4   r
   s      r   r   zChBRender.__init__M   s    d$78	kkbiiq1H/I
 	T334rzz!,K*LMN$..9r   c                 .    | j                   j                  S r   r   
autoRenderr   s    r   r   zChBRender.mapWindowPropertyY       ***r   c                 &    || j                   _        y r   rC   r   s     r   r   zChBRender.mapWindowProperty]       &+#r   c                 .    | j                   j                  S r   )r   autoRenderChangedr   s    r   r   z"ChBRender.mapWindowPropertyChangeda       111r   N	r)   r*   r+   r,   r   r-   r   r.   r   r   r   r   r0   r0   J   s=    8
 + + , ,2r   r0   c                   P    e Zd ZdZd Zed        Zej                  d        Zd Zy)ChBAlignExtentzCheckbox to select zoom behavior.

    Used by BufferedWindow (through MapFrame property).
    See tooltip for explanation.
    c                    t         j                  | |       d| _        t        j                  |t        j
                  t        d            | _        | j                  j                  | j                         | j                  j                  t        j                  t        d                   | j                  j                  t        j                  | j                         | j                          y )NalignExtentz)Align region extent based on display sizer3   zAlign region extent based on display size from center point. Default value for new map displays can be set up in 'User GUI settings' dialog.r7   rA   s      r   r   zChBAlignExtent.__init__l   s    d$78!	kkyy?@

 	T334JJ?		
 	$..9r   c                 .    | j                   j                  S r   r   rO   r   s    r   r   z ChBAlignExtent.mapWindowProperty   s    +++r   c                 &    || j                   _        y r   rQ   r   s     r   r   z ChBAlignExtent.mapWindowProperty   s    ',$r   c                 .    | j                   j                  S r   )r   alignExtentChangedr   s    r   r   z'ChBAlignExtent.mapWindowPropertyChanged   s    222r   NrK   r   r   r   rM   rM   e   s?    , , , - -3r   rM   c                   b     e Zd ZdZd Zed        Zej                  d        Zd Z fdZ	 xZ
S )ChBResolutionz+Checkbox to select used display resolution.c                    t         j                  | |       || _        d| _        t	        j
                  |t        j                  t        d            | _        | j                  j                  | j                         | j                  j                  t	        j                  t        d                   | j                  j                  t        j                  | j                         | j!                          y )N
resolutionz6Constrain display resolution to computational settingsr3   zConstrain display resolution to computational region settings. Default value for new map displays can be set up in 'User GUI settings' dialog.r   r   mapFramer8   r9   r:   r;   r<   r   r   r   r=   r>   r?   r@   r(   r"   r	   r4   mapframer
   s       r   r   zChBResolution.__init__   s    d$78  	kkyyLM

 	T334JJ?		
 	$..9r   c                 .    | j                   j                  S r   r   rX   r   s    r   r   zChBResolution.mapWindowProperty   rE   r   c                 &    || j                   _        y r   r^   r   s     r   r   zChBResolution.mapWindowProperty   rG   r   c                 .    | j                   j                  S r   )r   resolutionChangedr   s    r   r   z&ChBResolution.mapWindowPropertyChanged   rJ   r   c                     t         |   |       | j                  j                  r)| j                  j                         j                          yy)z'Update display when toggle display modeNsuperr(   r   rD   rZ   	GetWindow	UpdateMapr	   r'   	__class__s     r   r(   zChBResolution._onToggle   s?    %  &&MM##%//1 'r   r)   r*   r+   r,   r   r-   r   r.   r   r(   __classcell__rh   s   @r   rV   rV      sH    5. + + , ,22 2r   rV   c                   b     e Zd ZdZd Zed        Zej                  d        Zd Z fdZ	 xZ
S )ChBShowRegionz?Checkbox to enable and disable showing of computational region.c                    t         j                  | |       || _        d| _        t	        j
                  |t        j                  t        d            | _        | j                  j                  | j                         | j                  j                  t	        j                  t        d                   | j                  j                  t        j                  | j                         | j!                          y )N
showRegionzShow computational extentr3   zShow/hide computational region extent (set with g.region). Display region drawn as a blue box inside the computational region, computational region inside a display region as a red box).rY   r[   s       r   r   zChBShowRegion.__init__   s    d$78  	kkbiiq1L/M
 	T334JJ%		
 	$..9r   c                 .    | j                   j                  S r   r   ro   r   s    r   r   zChBShowRegion.mapWindowProperty   rE   r   c                 &    || j                   _        y r   rq   r   s     r   r   zChBShowRegion.mapWindowProperty   rG   r   c                 .    | j                   j                  S r   )r   showRegionChangedr   s    r   r   z&ChBShowRegion.mapWindowPropertyChanged   rJ   r   c                     t         |   |       | j                  j                  r+| j                  j                         j                  d       yy)znShows/Hides extent (comp. region) in map canvas.

        Shows or hides according to checkbox value.
        F)r2   Nrc   rg   s     r   r(   zChBShowRegion._onToggle   sF    
 	%  &&MM##%//u/= 'r   ri   rk   s   @r   rm   rm      sH    I. + + , ,2	> 	>r   rm   c                   b     e Zd ZdZd Zed        Zej                  d        Zd Z fdZ	 xZ
S )ChBProjectionz*Checkbox to enable user defined projectionc                    t         j                  | |       d| _        t        d      | _        t        j                  |t
        j                  | j                        | _        | j                  j                  | j                         | j                  j                  t        j                  t        d                   | j                  j                  t
        j                  | j                         | j!                          y )NuseDefinedProjectionz$Display coordinates in different CRSr3   zReproject coordinates displayed in the statusbar. Coordinate reference system can be specified in GUI preferences dialog (tab 'Projection'))r   r   r8   r<   defaultLabelr9   r:   r;   r   r   r   r=   r>   r?   r@   r(   r"   rA   s      r   r   zChBProjection.__init__   s    d$78*	DEkkBIITEVEVWT334JJ)		
 	$..9r   c                 .    | j                   j                  S r   r   ry   r   s    r   r   zChBProjection.mapWindowProperty  s    444r   c                 &    || j                   _        y r   r|   r   s     r   r   zChBProjection.mapWindowProperty  s    05-r   c                 .    | j                   j                  S r   )r   useDefinedProjectionChangedr   s    r   r   z&ChBProjection.mapWindowPropertyChanged  s    ;;;r   c                 "   t         |   |       | j                  j                  }|rBt	        d      j                  | j                  |      }| j                  j                  |       y | j                  j                  | j                         y )Nz{label} (EPSG: {epsg}))r6   epsg)	rd   r(   r   r   r<   formatrz   r   SetLabel)r	   r'   r   r6   rh   s       r   r(   zChBProjection._onToggle  sv    % $$./66''d 7 E KK  'KK  !2!23r   ri   rk   s   @r   rw   rw      sH    4& 5 5 6 6<	4 	4r   rw   c                   b    e Zd ZdZd Zd Zd Zd Zed        Z	e	j                  d        Z	d Zy	)
RBShowInStatusbarz'Radiobox managing widgets in statusbar.c                    t         j                  | |       d| _        || _        | j                  j	                         }t        j                  |t
        j                  d|dt
        j                        | _	        | j                  | j                         | j                          | j                  j                  t
        j                  | j                         | j!                          y )NshowInStatusbarzDisplayed content   )r4   r5   r6   choicesmajorDimensionstyle)r   r   r8   statusbarManagerGetItemLabelsr9   RadioBoxr;   RA_SPECIFY_COLSr   r   r   _disableItemsr?   EVT_RADIOBOXr(   r"   )r	   r4   r
   	sbmanagerr   s        r   r   zRBShowInStatusbar.__init__  s    d$78%	 )''557kkyy%$$
 	t--.$..9r   c                 :    | j                   j                  |       y r   )r   SetSelection)r	   modes     r   r   zRBShowInStatusbar._setValue1  s      &r   c                 6    | j                   j                         S r   )r   GetSelectionr   s    r   r   zRBShowInStatusbar.GetValue4  s    {{''))r   c                     | j                   j                  j                         D ]  }| j                  j	                  |d       ! y)zDisables a radiobox optionsF)nenableN)r   disabledItemskeysr   
EnableItem)r	   items     r   r   zRBShowInStatusbar._disableItems7  s=    ))77<<> 	9DKK""T%"8	9r   c                 .    | j                   j                  S r   r   sbItemr   s    r   r   z#RBShowInStatusbar.mapWindowProperty<  s    &&&r   c                 &    || j                   _        y r   r   r   s     r   r   z#RBShowInStatusbar.mapWindowProperty@  s    "'r   c                 .    | j                   j                  S r   )r   sbItemChangedr   s    r   r   z*RBShowInStatusbar.mapWindowPropertyChangedD  s    ---r   N)r)   r*   r+   r,   r   r   r   r   r-   r   r.   r   r   r   r   r   r     sL    1('*9
 ' ' ( (.r   r   c                   j    e Zd ZdZ ed      dej                  ej                  z  fdZd Z	d Z
d Zy)	MapDisplayPropertiesDialogzMap Display properties dialogzMap Display Settings)i,  c                 :   t         j                  j                  | |t         j                  ||       || _        || _        || _        || _        || _        || _	        t        j                  | t         j                  t         j                        | _        | j                  | j                         | j                  | j                         t        | t         j                         | _        | j%                  t         j                          | j'                          y )N)r4   r5   titler   )r4   r5   r   )r4   )r9   Dialogr   r;   r4   r   sizer\   r
   r   Notebook
BK_DEFAULTnotebook_createDisplayPage_createStatusBarPager   ID_CLOSEbtnCloseSetEscapeId_layout)r	   r4   r\   
propertiesr   r   r   r   s           r   r   z#MapDisplayPropertiesDialog.__init__K  s     			4299EQVW
	 #-  ) 4BIIR]]St}}5!!!7tR[[1%r   c                 B   t        j                         }|j                  | j                         |j	                          t        j
                  t         j                        }|j                  | j                  dt         j                  t         j                  z  d       |j                  |dt         j                  t         j                  z  d       | j                  |       | j                  | j                                | j                  | j                         y)zLayout windowr      
proportionflagborderr   N)r9   StdDialogButtonSizer	AddButtonr   RealizeBoxSizerVERTICALAddr   EXPANDALLSetSizer
SetMinSizeGetBestSizeSetSizer   )r	   btnStdSizer	mainSizers      r   r   z"MapDisplayPropertiesDialog._layouti  s     --/dmm,KK,	dmm		BFF8JSTUkabii"&&6HQRSi ((*+TYYr   c                 x   t        j                  |t        j                        }|j	                  dd       |j                  |t        d             t        j                  t        j                        }t        || j                        | _        |j                  | j                  j                         dt        j                  t        j                  z  d	       t!        || j                        | _        |j                  | j"                  j                         dt        j                  t        j                  z  d	       t%        || j&                  | j                        | _        |j                  | j(                  j                         dt        j                  t        j                  z  d	       t+        || j&                  | j                        | _        |j                  | j,                  j                         dt        j                  t        j                  z  d	       |j/                  |       y
)z)Create notebook page for display settingsr4   r5   FTscroll_xscroll_yGeneralpagetextr      r   N)SPScrolledPanelr9   r;   SetupScrollingAddPager<   r   r   r0   r
   autoRenderingr   r   r   r   rM   rO   rV   r\   compResolutionrm   showCompExtentr   r	   r4   panelsizers       r   r   z-MapDisplayPropertiesDialog._createDisplayPagex  s      299=ed;E)5 BKK( 'ud.F.FG		((*RVV#	 	 	
 *%1I1IJ		&&(RVV#	 	 	
 ,4==$":":
 			))+RVV#	 	 	
 ,4==$":":
 			))+RVV#	 	 	
 	ur   c                    t        j                  |t        j                        }|j	                  dd       |j                  |t        d             t        j                  t        j                        }t        || j                  | j                        | _        |j                  | j                  j                         dt        j                  t        j                   z  d	
       t#        || j                        | _        |j                  | j$                  j                         dt        j                  t        j                   z  d	
       |j'                  |       y)z+Create notebook page for statusbar settingsr   FTr   z
Status barr   )r4   r
   r   r   r   r   N)r   r   r9   r;   r   r   r<   r   r   r   r
   r   shownInStatusbarr   r   r   r   rw   
projectionr   r   s       r   r   z/MapDisplayPropertiesDialog._createStatusBarPage  s      299=ed;E,8BKK( 1 $ 8 8++!

 			!!++-RVV#	 	 	
 (t/G/GH		OO%%'RVV#	 	 	
 	ur   N)r)   r*   r+   r,   r<   r9   DEFAULT_DIALOG_STYLERESIZE_BORDERr   r   r   r   r   r   r   r   r   H  s<    ' &'%%(8(88< 2hr   r   )r,   r9   wx.lib.scrolledpanellibscrolledpanelr   gui_core.wrapr   r   r0   rM   rV   rm   rw   r   r   r   r   r   r   <module>r      s   2 
 ! !  ( (V2 26&3\ &3R+2L +2\.>L .>b*4L *4Z+. +.\B Br   