
    h%                        S SK Jr  S SKJrJrJr  S SKrS SKJrJ	r	J
r
JrJrJrJr  S SKJr  S SKJr  S SKJr  SS	KJrJrJr  S
rSrSrSrSrS r " S S\R>                  5      r SS jr!SS jr"g)    )annotations)IteratorIterableOptionalN)	QtWidgetsQtGuiQActionQMessageBoxQFileDialogQtQModelIndex)Drawing)Body)DXFStructureError   )AcisDataBinaryAcisDataTextAcisDatazACIS Structure Browseri   i   g?
monospacedc                     [         R                  " [        5      n U R                  [         R                  R                  5        U $ N)r   QFontFONT_FAMILYsetStyleHint	Monospace)fonts    R/var/www/html/env/lib/python3.13/site-packages/ezdxf/addons/acisbrowser/browser.py	make_fontr      s-    ;;{#Dekk++,K    c                     ^  \ rS rSr  S   SU 4S jjjrS rS rS rS rS r	SSS	.     SS
 jjr
S rS rSS jrSS jrS S jrS rS rS rS!S jrSS jrS"S jrS#S jrS#S jrS$S jrS%S jrSrU =r$ )&AcisStructureBrowser"    c                r  > [         TU ]  5         S U l        / U l        [	        5       U l        U R                  5       U l        U R                  5       U l	        [        R                  " U 5      U l        U R                  5         U R                  5         U(       a  U R                  U5        OU R!                  ["        5        U R%                  U R                  5        U R'                  U R)                  5       5        U R+                  [,        [.        5        U R1                  5         U(       aQ   [3        US5        U R5                  U5      (       d-  SU S3nU R                  R7                  U5        [9        U5        g g g ! [:         a/    SU S3nU R                  R7                  U5        [9        U5         g f = f)N   zHandle 'z' not found.z"Given handle is not a hex value: '')super__init__docacis_entitiesr   current_acis_entitymake_entity_selectorentity_selectormake_content_vieweracis_content_viewerr   
QStatusBar	statusbarsetup_actions
setup_menuload_dxfsetWindowTitleAPP_NAMEsetStatusBarsetCentralWidgetmake_central_widgetresizeBROWSER_WIDTHBROWSER_HEIGHTconnect_slotsintgoto_handleshowMessageprint
ValueError)selffilenamehandlemsg	__class__s       r   r(   AcisStructureBrowser.__init__#   s`   
 	&*-/#+: #88:#'#;#;#= "--d3MM(#)$..)d6689M>2
FB ''//$VHL9CNN..s3#J 0   :6(!D**3/c
s   ,E= =6F65F6c                .    [         R                  " U 5      $ r   )r   QListWidgetrC   s    r   r,   )AcisStructureBrowser.make_entity_selectorH   s    $$T**r   c                    [         R                  " U 5      nUR                  S5        UR                  [         R                  R                  5        U$ )NT)r   QPlainTextEditsetReadOnlysetLineWrapModeNoWrap)rC   viewers     r   r.   (AcisStructureBrowser.make_content_viewerK   s?    ))$/4 y77>>?r   c                d   [         R                  " [        R                  5      nUR	                  U R
                  5        UR	                  U R                  5        [        [        [        -  5      n[        U-
  nUR                  X#/5        UR                  SS5        UR                  SS5        U$ )Nr   Fr   )r   	QSplitterr   
Horizontal	addWidgetr-   r/   r>   r;   SELECTOR_WIDTH_FACTORsetSizessetCollapsible)rC   	containerselector_widthentity_view_widths       r   r9   (AcisStructureBrowser.make_central_widgetQ   s    ''6	D001D445]-BBC)N:N>?  E*  E*r   c                    U R                   R                  R                  U R                  5        U R                   R                  R                  U R                  5        g r   )r-   clickedconnectacis_entity_activated	activatedrK   s    r   r=   "AcisStructureBrowser.connect_slots\   sB    $$,,T-G-GH&&..t/I/IJr   c                D   U R                  SU R                  SS9U l        U R                  SU R                  SS9U l        U R                  SU R
                  SS9U l        U R                  SU R                  S	S9U l        U R                  S
U R                  SS9U l
        g )Nz&Open DXF File...zCtrl+O)shortcutzReload DXF FilezCtrl+Rz&Export Current Entity View...zCtrl+Ez&Export Raw SAT/SAB Data...zCtrl+Wz&QuitzCtrl+Q)make_actionopen_dxf_open_action
reload_dxf_reload_actionexport_entity_export_entity_actionexport_raw_entity_export_raw_data_actionclose_quit_actionrK   s    r   r2   "AcisStructureBrowser.setup_actionsa   s     ,, - 
 #..OO / 

 &*%5%5, &6 &
"
 (,'7'7)"" (8 (
$
 !,,TZZ( - 
r   )rf   tipc                   [        X5      nU(       a  UR                  U5        U(       a  UR                  U5        UR                  R	                  U5        U$ r   )r	   setShortcut
setToolTip	triggeredra   )rC   nameslotrf   rs   actions         r   rg    AcisStructureBrowser.make_actionx   sI     $x(c"  &r   c                   U R                  5       nUR                  S5      nUR                  U R                  5        UR                  U R                  5        UR                  5         UR                  U R                  5        UR                  U R                  5        UR                  5         UR                  U R                  5        g )Nz&File)	menuBaraddMenu	addActionri   rk   addSeparatorrm   ro   rq   )rC   menu	file_menus      r   r3   AcisStructureBrowser.setup_menu   s    ||~LL)	D--.D//0 D667D889 D--.r   c                x    [         R                  R                  U SSS9u  pU(       a  U R                  U5        g g )NzSelect DXF filezDXF Documents (*.dxf *.DXF))captionfilter)r   r   getOpenFileNamer4   )rC   path_s      r   rh   AcisStructureBrowser.open_dxf   s>    ''77%0 8 

 MM$ r   c                <    [         R                  " U5      n[        [        U5      5      n[        U5      (       aR  X l
        U R                  U5        U R                  U5        U R                  R                  U R                  5       5        g SU S3n[        R                   " U SU5        g ! [         a+  n[        R                  " U S[        U5      5         S nAg S nAf[         a1  n[        R                  " U SSU S[        U5       35         S nAg S nAff = f)NzLoading ErrorzDXF Structure ErrorzInvalid DXF file "z": z
DXF file 'z' contains no ACIS data)ezdxfreadfileIOErrorr
   criticalstrr   listget_acis_entitieslenr)   set_acis_entitiesupdate_titler1   r@   make_loading_messageinformation)rC   r   r)   eentitiesrF   s         r   r4   AcisStructureBrowser.load_dxf   s    	..&C )#./x==H""8,d#NN&&t'@'@'BCtf$;<C##D/3?%  	  A?  	  %$TF#c!fX6
 	s#   B- -
D7!CD*'DDc                    U R                   c   eU R                   R                  nUS:  a  SOSnSU R                   R                   SU SU S3$ )NAC1027SABSATzLoaded DXF file has version /z and contains z data)r)   
dxfversionacad_release)rC   r   	acis_types      r   r   )AcisStructureBrowser.make_loading_message   sZ    xx###XX((
'83E	-dhh.C.C-DAj\	{%1 	1r   c                Z    Xl         U R                  U5        U R                  US   5        g Nr   )r*   update_entity_selectorset_current_acis_entity)rC   r   s     r   r   &AcisStructureBrowser.set_acis_entities   s(    %##H-$$Xa[1r   c                    U R                   R                  U R                  5      nU R	                  U R
                  R                  5        US:  a  U R                  U R                   U   5        g g ! [         a    Sn NYf = f)Nr   )r*   indexr+   
IndexErrorr4   r)   rD   r   rC   r   s     r   rj   AcisStructureBrowser.reload_dxf   sv    	&&,,T-E-EFE 	dhh''(19((););E)BC   	E	s   %A2 2B Bc                    U R                  5       nUc  g [        R                  " U SUR                  5        SUR                  R
                   S3SS9u  p#U(       a  [        U R                  U5        g g )NzExport Current Entity View-z.txtzText Files (*.txt *.TXT)r   dirr   )get_current_dxf_entityr   getSaveFileNamedxftypedxfrE   
write_datar+   )rC   
dxf_entityr   r   s       r   rl   "AcisStructureBrowser.export_entity   ss    002
--0%%'(*..*?*?)@E-	
 t//6 r   c                6   U R                  5       nUc  g UR                  5        SUR                  R                   3nUR                  nU(       a  SnUS-  nOSnUS-  n[
        R                  " U SUUS9u  pVU(       ax  U(       a1  [        US5       nUR                  UR                  5        S S S 5        g [        US	5       nUR                  S
R                  UR                  5      5        S S S 5        g g ! , (       d  f       g = f! , (       d  f       g = f)Nr   z(Standard ACIS Binary Files (*.sab *.SAB)z.sabz&Standard ACIS Text Files (*.sat *.SAT)z.satzExport ACIS Raw Datar   wbwt
)r   r   r   rE   has_binary_datar   r   openwritesabjoinsat)rC   r   rD   r   filter_r   r   fps           r   rn   &AcisStructureBrowser.export_raw_entity   s    002
 ((*+1Z^^-B-B,CD((@GH>GH--*	
 $%HHZ^^, &% $%HHTYYz~~67 &% %% &%s   C9+D
9
D

Dc                    U R                   nUR                  (       a  U R                  c  g U R                  R                  R	                  UR                  5      $ r   )r+   rE   r)   entitydbget)rC   currents     r   r   +AcisStructureBrowser.get_current_dxf_entity   s?    **~~!1xx  $$W^^44r   c                8    U R                  [         SU 35        g )Nz - )r5   r6   )rC   r   s     r   r   !AcisStructureBrowser.update_title   s    xjD623r   c                    [        U R                  5      S:X  a  g  U R                  U R                  UR                  5          5        g ! [         a!    U R                  U R                  S   5         g f = fr   )r   r*   r   rowr   r   s     r   rb   *AcisStructureBrowser.acis_entity_activated   sg    t!!"a'	@((););EIIK)HI 	@((););A)>?	@s   ,A	 	(A43A4c                B    U(       a  Xl         U R                  U5        g g r   )r+   update_acis_content_viewer)rC   entitys     r   r   ,AcisStructureBrowser.set_current_acis_entity  s    '-$++F3 r   c                    U R                   nUR                  5         UR                  SR                  UR                  5      5        g )Nr   )r/   clearsetPlainTextr   lines)rC   r   rR   s      r   r   /AcisStructureBrowser.update_acis_content_viewer  s1    ))DIIfll34r   c                    U R                   nUR                  5         UR                  U Vs/ s H  o3R                  PM     sn5        g s  snf r   )r-   r   addItemsrx   )rC   r   rR   r   s       r   r   +AcisStructureBrowser.update_entity_selector  s6    %%2A232s   A	c                p    U R                    H&  nUR                  U:X  d  M  U R                  U5          g   g)NTF)r*   rE   r   )rC   rE   r   s      r   r?    AcisStructureBrowser.goto_handle  s4    ((F}}&,,V4 ) r   )rm   ro   ri   rq   rk   r/   r*   r+   r)   r-   r1   )r#   r#   )rD   r   rE   r   )rf   r   rs   r   returnr	   )r   r   )r   r   )r   zlist[AcisData])r   zOptional[Body])r   r   )r   r   )r   zIterable[AcisData])rE   r   r   bool)__name__
__module____qualname____firstlineno__r(   r,   r.   r9   r=   r2   rg   r3   rh   r4   r   r   rj   rl   rn   r   r   rb   r   r   r   r?   __static_attributes____classcell__)rG   s   @r   r!   r!   "   s     ## # #J+	K

8 
   
 	/ @.12
D78654@4
5
4
 r   r!   c              #  Z  #    U R                   R                  5        H  n[        U[        5      (       d  M  UR                  R
                  nSU SUR                  5        3nUR                  (       a  [        UR                  X25      v   Mq  [        UR                  X25      v   M     g 7f)N<z> )r   values
isinstancer   r   rE   r   r   r   r   r   r   )r)   r   rE   rx   s       r   r   r     sy     \\  "aUU\\Fvhb.D  $QUUD99"155$77 #s   1B+A4B+c                     [        US5       nUR                  SR                  U R                  5      5        S S S 5        g ! , (       d  f       g = f! [         a     g f = f)Nr   r   )r   r   r   r   r   )r   r   r   s      r   r   r   #  sI    $HHTYYv||,-  s-   A +AA 
AA A 
A A )r)   r   r   zIterator[AcisData])r   r   r   r   )#
__future__r   typingr   r   r   r   ezdxf.addons.xqtr   r   r	   r
   r   r   r   ezdxf.documentr   ezdxf.entitiesr   ezdxf.lldxf.constr   datar   r   r   r6   r;   r<   rX   r   r   QMainWindowr!   r   r    r   r   <module>r      ss    # / /    #  / 8 8 $ s900 sl8r   