Ë
    c­øcˆ  ã                   óF   — d dl Z d dlmZ ddlmZ ddlmZ  G d„ de«      Zy)é    N)ÚGdké   )ÚAbstractCanvasTool)ÚOptionsBarRotatec                   óš   ‡ — e Zd Zd Zˆ fd„Zd„ Zd„ Zd„ Zd„ Zˆ fd„Z	d„ Z
d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ˆ xZS )Ú
ToolRotatec                 óT  •— t         ‰| �  dt        d«      d|«       d| _        d| _        d| _        d| _        | j                  d| j                  «       | j                  d| j                  «       | j                  d	| j                  «       | j                  d
| j                  «       y )NÚrotateÚRotateztool-rotate-symbolicÚpointerFr   zrotate-clockwisezrotate-counter-cwzrotate-flip-hzrotate-flip-v)ÚsuperÚ__init__Ú_Úcursor_nameÚflip_hÚflip_vÚangle_pressÚadd_tool_action_simpleÚon_right_clickedÚon_left_clickedÚon_horizontal_clickedÚon_vertical_clicked)ÚselfÚwindowÚ	__class__s     €ú5/usr/lib/python3/dist-packages/drawing/tool_rotate.pyr   zToolRotate.__init__   s“   ø€ Ü�'Ñ�8œQ˜x›[Ð*@À&ÔIØ€$ÔØ€$„+Ø€$„+Ø€$Ôà×ÑÐ0°$×2GÑ2GÔHØ×ÑÐ1°4×3GÑ3GÔHØ×Ñ˜o¨t×/IÑ/IÔJØ×Ñ˜o¨t×/GÑ/GÕHó    c                 ór   — d| _         | j                  j                  j                  | j                   | «       y )Nr
   )Úpane_idr   Úoptions_managerÚtry_add_bottom_pane©r   s    r   Útry_build_panezToolRotate.try_build_pane&   s'   € Ø€$„,Ø‡+�+×Ñ×1Ñ1°$·,±,ÀÕEr   c                 óŠ   — t        | «      }|j                  | _        | j                  j                  d| j                  «       |S )Nzvalue-changed)r   Ú	angle_btnÚconnectÚon_angle_changed)r   Úpanes     r   Úbuild_bottom_panezToolRotate.build_bottom_pane*   s6   € Ü	˜$Ó	€$Ø—>‘>€$„.Ø‡.�.×Ñ˜¨$×*?Ñ*?Ô@Ø	€+r   c                 ó   — t        d«      S )NzRotating options)r   r"   s    r   Úget_options_labelzToolRotate.get_options_label0   s   € Ü	
ÐÓ	Ðr   c                 ó´   — | j                   rt        d«      }d }n&t        d«      }| j                  dz   t        d«      z   }||g}t        t	        d |«      «      S )NzRotating the selectionzRotating the canvasz - z&Don't forget to confirm the operation!)Úapply_to_selectionr   ÚlabelÚlistÚfilter)r   Úlabel_actionÚlabel_confirmÚ	full_lists       r   Úget_editing_tipszToolRotate.get_editing_tips3   sa   € Ø	×ÒÜÐ,Ó-€<Ø�=äÐ)Ó*€<Ø—:‘: Ñ%ÜÐFÓGñH€=ð ˜]Ð+€)Ü	Œf�T˜9Ó%Ó	&Ð&r   c                 óÊ   •— t         ‰| �  «        d| _        d| _        | j                  j                  d«       | j                  «        | j                  rd| _        y d| _        y )NFg        Úmover   )	r   Úon_tool_selectedr   r   r%   Ú	set_valueÚbuild_and_do_opr-   r   )r   Úargsr   s     €r   r7   zToolRotate.on_tool_selectedB   sU   ø€ Ü�'ÑÔØ€$„+Ø€$„+Ø‡.�.×Ñ˜3ÔØ×ÑÔØ	×ÒØ€4Õð  €4Õr   c                 óZ  — | j                  |j                  «       d| j                  v r@|j                  dk(  r| j	                  «        y |j                  dk(  r| j                  «        y | j                  s@|j                  dk(  r| j                  «        y |j                  dk(  r| j                  «        y | j                  «       j                  «       \  }}||z
  }||z
  }t        j                  ||«      dz  t        j                  z  }	| j                  «       t        |	«      z
  | _        y )NÚSHIFTr   é   é´   )Úupdate_modifier_stateÚstateÚ_modifier_keysÚbuttonr   r   r-   r   r   Úget_selectionÚget_center_coordsÚmathÚatan2ÚpiÚ	get_angleÚintr   )
r   ÚeventÚsurfaceÚevent_xÚevent_yÚcenter_xÚcenter_yÚdelta_x0Údelta_y0Úpress_as_degreess
             r   Úon_press_on_areazToolRotate.on_press_on_areaQ   s  € Ø×Ñ˜UŸ[™[Ô)Ø�×#Ñ#Ñ#Ø‡l�l�aÒØ×ÑÔ ð 
ð 	�‰˜ÒØ×ÑÔØ	Ø×"Ò"Ø‡l�l�aÒØ×ÑÔð 
ð 	�‰˜ÒØ×ÑÔØ	à×)Ñ)Ó+×=Ñ=Ó?Ñ€(ˆHØ˜Ñ€(Ø˜Ñ€(Ü—j‘j ¨8Ó4°sÑ:¼d¿g¹gÑEÐØ—^‘^Ó%¬Ð,<Ó(=Ñ=€$Õr   c                 ór  — | j                   sy | j                  «       j                  «       \  }}||z
  }||z
  }	t        j                  ||	«      dz  t        j
                  z  }
| j                  j                  t        |
«      | j                  z   «       |r"| j                  «       }| j                  |«       y y )Nr>   )r-   rC   rD   rE   rF   rG   r%   r8   rI   r   Úbuild_operationÚdo_tool_operation)r   rJ   rK   rL   rM   ÚrenderrN   rO   Údelta_xÚdelta_yÚrelease_angleÚ	operations               r   Úon_motion_on_areazToolRotate.on_motion_on_areaf   s¢   € Ø	×	 Ò	 Ø	Ø×)Ñ)Ó+×=Ñ=Ó?Ñ€(ˆHØ�wÑ€'Ø�wÑ€'Ü—J‘J˜w¨Ó0°3Ñ6¼4¿7¹7ÑB€-Ø‡.�.×Ñœ3˜}Ó-°×0@Ñ0@Ñ@ÔAÙØ×#Ñ#Ó%€9Ø×Ñ˜)Õ$ð r   c                 ó,   — | j                  ||||«       y ©N)r\   )r   rJ   rK   rL   rM   s        r   Úon_release_on_areazToolRotate.on_release_on_arear   s   € Ø×Ñ˜ ¨°'Õ:r   c                 ó6   — | j                   j                  «       S r^   )r%   Úget_value_as_intr"   s    r   rH   zToolRotate.get_anglew   s   € Ø	�‰×	(Ñ	(Ó	*Ð*r   c                 ó`   — | j                  «       }| j                  j                  |dz
  «       y ©NéZ   ©Úget_normalized_angler%   r8   ©r   r:   Úangles      r   r   zToolRotate.on_right_clickedz   ó&   € Ø
×
#Ñ
#Ó
%€%Ø‡.�.×Ñ˜5 2™:Õ&r   c                 ó`   — | j                  «       }| j                  j                  |dz   «       y rc   re   rg   s      r   r   zToolRotate.on_left_clicked~   ri   r   c                 óH   — | j                    | _         | j                  «        y r^   )r   r9   ©r   r:   s     r   r   zToolRotate.on_vertical_clicked‚   ó   € Ø—K‘K�€$„+Ø×ÑÕr   c                 óH   — | j                    | _         | j                  «        y r^   )r   r9   rl   s     r   r   z ToolRotate.on_horizontal_clicked†   rm   r   c                 óN   — | j                  «       dz  }t        |dz  «      dz  }|S )Néh  rd   )rH   rI   rg   s      r   rf   zToolRotate.get_normalized_angleŠ   s*   € Ø
�.‰.Ó
˜SÑ
 €%Ü
ˆe�B‰h‹-˜"Ñ
€%Ø	€,r   c                 ó¦   — | j                  «       dk(  s| j                  «       dk(  r| j                  j                  d«       | j                  «        y )Nrp   i˜þÿÿr   )rH   r%   r8   r9   rl   s     r   r'   zToolRotate.on_angle_changed�   s=   € Ø	‡^�^Ó˜Ò §¡Ó 0°DÒ 8Ø‡>�>×Ñ˜AÔØ×ÑÕr   c                 óD  — d}d}|| j                  «       j                  j                  «       z   }|| j                  «       j                  j                  «       z   }| j                  «       j	                  ||||| j
                  d«      \  }}}}| j                  |||«       y )Nr   F)Ú	get_imageÚtemp_pixbufÚ	get_widthÚ
get_heightÚget_corrected_coordsr-   Ú_draw_temp_pixbuf)r   ÚareaÚcairo_contextÚx1Úy1Úx2Úy2s          r   Úon_draw_abovezToolRotate.on_draw_above–   s‘   € Ø€"Ø€"Ø	ˆD�N‰NÓ×(Ñ(×2Ñ2Ó4Ñ4€"Ø	ˆD�N‰NÓ×(Ñ(×3Ñ3Ó5Ñ5€"Ø—>‘>Ó#×8Ñ8¸¸RÀÀRØ+/×+BÑ+BÀEóK�.€"€bˆ"ˆbà×Ñ˜¨¨BÕ/r   c           	      óˆ   — | j                   | j                  ddd| j                  «       | j                  | j                  dœ}|S )NTr   )Útool_idÚis_selectionÚ
is_previewÚlocal_dxÚlocal_dyrh   r   r   )Úidr-   rH   r   r   )r   r[   s     r   rU   zToolRotate.build_operation¡   sB   € à�g‰gØ×*Ñ*ØØØØ�N‰NÓØ�[‰[Ø�[‰[ñ	€)ð 
Ðr   c                 ó"  — | j                  |«       |d   }|d   }|d   }|d   r| j                  «       }n| j                  «       }|dk  r|dz  }t        |dz  «      dz  }|dz  }|}|r|j	                  d«      }|r|j	                  d	«      }|j                  |«      }|dk7  r»t        j                  |dd «      }	|	j                  | j                  «       | j                  «       «       | j                  ||	j                  «       |	j                  «       «      }
| j                  |	|
«      }t        j                  |dd|j                  «       |j                  «       «      }| j                  «       j!                  |«       | j#                  |«       y )
Nrh   r   r   r‚   r   rp   rd   TF)Ústart_tool_operationÚget_selection_pixbufÚget_main_pixbufrI   ÚflipÚrotate_simpler   Ú cairo_surface_create_from_pixbufÚset_device_scaleÚscale_factorÚ_get_rotation_matrixru   rv   Úget_deformed_surfaceÚpixbuf_get_from_surfacers   Úset_temp_pixbufÚcommon_end_operation)r   r[   rh   r   r   Úsource_pixbufÚgdk_rotationÚcairo_rotationÚ
new_pixbufÚsurface0ÚcoefsÚnew_surfaces               r   rV   zToolRotate.do_tool_operation®   s‰  € Ø×Ñ˜IÔ&Ø
�GÑ
€%Ø�XÑ€&Ø�XÑ€&Øˆ~ÒØ×,Ñ,Ó.�=à×'Ñ'Ó)€=à
ˆQ‚YØˆC�<€5Ü�U˜R‘Z“ 2Ñ%€,Ø˜2‘:€.ð €*ñ Ø—‘ Ó%€:ÙØ—‘ Ó&€:ð ×'Ñ'¨Ó5€*ð �qÒÜ×2Ñ2°:¸qÀ$ÓG€8Ø×Ñ˜T×.Ñ.Ó0°$×2CÑ2CÓ2EÔFØ×$Ñ$ ^Ø#×-Ñ-Ó/°×1DÑ1DÓ1FóH€5à×*Ñ*¨8°UÓ;€;Ü×+Ñ+¨K¸¸AØ ×*Ñ*Ó,¨k×.DÑ.DÓ.FóH€:ð ‡.�.Ó×"Ñ" :Ô.Ø×Ñ˜IÕ&r   c                 ó(  — t         j                  |z  dz  }t        j                  |«      }t        j                  |«      }dt        j                  |«      z  }t        j                  |«      }t	        d||z  «      }	t	        d||z  «      }
|||||	|
gS )zÀTransform an angle (in degrees) to the xx/yx/xy/yy coefs expected by
		cairo. Due to previously performed modifications to the data, the angle
		will be between 0 (excluded) and 90 (excluded).r>   éÿÿÿÿr   )rE   rG   ÚcosÚsinÚmax)r   rh   ÚwidthÚheightÚradÚxxÚxyÚyxÚyyÚx0Úy0s              r   r�   zToolRotate._get_rotation_matrix×   s‚   € ô 	�‰�%‰˜#Ñ€#ä‡x�x�ƒ}€"Ü‡x�x�ƒ}€"Ø	ŒD�H‰H�S‹MÑ€"Ü‡x�x�ƒ}€"ä
ˆ1ˆf�r‰kÓ€"Ü
ˆ1ˆe�b‰jÓ€"à
ˆb�"�b˜"˜bÐ	!Ð!r   )T)Ú__name__Ú
__module__Ú__qualname__Ú__gtype_name__r   r#   r)   r+   r4   r7   rS   r\   r_   rH   r   r   r   r   rf   r'   r   rU   rV   r�   Ú__classcell__)r   s   @r   r   r      so   ø„ Ø€ô
IòFòòò'ô
 ò>ó*
%ò;ò
+ò'ò'òòòò
ò0òò''öR"r   r   )rE   Úgi.repositoryr   Úabstract_transform_toolr   Úoptionsbar_rotater   r   © r   r   ú<module>r³      s"   ðó$ Ý Ý 7Ý /ôN"Ð#õ N"r   