Subversion Repositories Kolibri OS

Rev

Rev 7415 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. ;FigureInit, (¢à¥¬. áâà.), (Object.FigData)
  3.  
  4. ;add_object_in_list, ___, ___, (¢à¥¬. áâà.), (Object.FigData)
  5. ;       mov [Object.FigData], (tl_node_add(¢à¥¬. áâà.),tl_node_get_data)
  6.  
  7. ;draw_fig2d_litl, ___, pobj, (Object.FigData), ___, ___, ___
  8.  
  9. struct Object
  10.         OType dd ?
  11.         FigCount dd ?
  12.         FigData dd ? ;array pointers to Figures
  13.         MinX dq ?
  14.         MinY dq ?
  15.         SizeX dq ?
  16.         SizeY dq ?
  17.         WScale dq ? ;prewiew window scale
  18.         MScale dq ? ;mouse scale (show partition figure)
  19.         MCentrX dd ? ;mouse centr X
  20.         MCentrY dd ? ;mouse centr Y
  21.         Caption rb 32
  22. ends
  23.  
  24. struct Figure
  25.         OType dd ?
  26.         PoiCount dd ?
  27.         PoiData dd ?
  28.         MinX dq ?
  29.         MinY dq ?
  30.         SizeX dq ?
  31.         SizeY dq ?
  32.         WScale dq ? ;prewiew window scale (show all figure)
  33.         MScale dq ? ;mouse scale (show partition figure)
  34.         MCentrX dd ? ;mouse centr X
  35.         MCentrY dd ? ;mouse centr Y
  36.         Caption rb 32
  37. ends
  38.  
  39. struct Point
  40.         Prop dd ? ;prorerties
  41.         CoordX dq ? ;coord X
  42.         CoordY dq ? ;coord Y
  43. ends
  44.  
  45. txt_err_1 db 'Žè¨¡ª  ¯à¨ áç¨â뢠­¨¨ ®¡ê¥ªâ ',0
  46. txt_err_2 db 'Žè¨¡ª  ¯à¨ áç¨â뢠­¨¨ 䨣ãàë',0
  47. txt_err_3 db '¥ ­ ©¤¥­  â®çª  ¢ 䨣ãà¥',0
  48. txt_err_no_figure_select db '¥ ¢ë¡à ­  ª®¬ ­¤  ¤«ï ¯¥à¥¬¥é¥­¨ï',0
  49. txt_err_figure_is_0 db 'Š®¬ ­¤  ­¥ ¬®¦¥â ¡ëâì ᤢ¨­ãâ  ¢¢¥àå,',13,10,'®­  ¢ ­ ç «¥ ᯨ᪠.',0
  50. txt_err_figure_is_last db 'Š®¬ ­¤  ­¥ ¬®¦¥â ¡ëâì ᤢ¨­ãâ  ¢­¨§,',13,10,'®­  ¢ ª®­æ¥ ᯨ᪠.',0
  51. txt_err_no_point_del db '¥ ¬®¦­  㤠«¨âì ¢á¥ â®çª¨ ¨§ 䨣ãàë.',0
  52. txt_err_poi_is_0 db '¥ ¬®¦­  ¯¥à¥¬¥áâ¨âì â®çªã ¢¢¥àå,',13,10,'®­  ¢ ­ ç «¥ ᯨ᪠.',0
  53. txt_err_poi_is_last db '¥ ¬®¦­  ¯¥à¥¬¥áâ¨âì â®çªã ¢­¨§,',13,10,'®­  ¢ ª®­æ¥ ᯨ᪠.',0
  54. txt_err_no_1_point_sel db '‚ë¡¥à¨â¥ ­¥ ¡®«ìè¥ ®¤­®© â®çª¨.',0
  55.  
  56. txt_min_x db 'min x: ',0
  57. txt_min_y db 'min y: ',0
  58.  
  59. if lang eq ru
  60. ;
  61. ; rus
  62. ;
  63. txt_err_no_point_sel db '¥ ¢ë¡à ­ë â®çª¨.',0
  64. txt_err_no_point_sel_1 db '‚ë¡¥à¨â¥ ®¤­ã â®çªã.',0
  65. txt_but_cancel db 'Žâ¬¥­ ',0
  66. txt_but_apply db 'à¨¬¥­¨âì',0
  67. txt_but_create db '‘®§¤ âì',0
  68. txt_size_x db 'à §¬¥à x: ',0
  69. txt_size_y db 'à §¬¥à y: ',0
  70. txt_poi_sel: db '‚ë¡à ­® â®ç¥ª: '
  71. .end db 0
  72. txt_err_save_txt_file_0:
  73.         db '¥ ¬®£ã á®åà ­¨âì *.nc ä ©«.',0
  74. txt_err_save_txt_file_1:
  75.         db '¥ 㤠«®áì á®åà ­¨âì ¢¥áì *.nc ä ©«.',0
  76. txt_err_save_img_file:
  77.         db '¥ ¬®£ã á®åà ­¨âì *.png ä ©«.',0
  78. txt_obj: db 'Ž¡ê¥ªâ: ',39
  79. .end db 0
  80. else
  81. ;
  82. ; eng
  83. ;
  84. txt_err_no_point_sel db 'No select points.',0
  85. txt_err_no_point_sel_1 db 'Select one point.',0
  86. txt_but_cancel db 'Cancel',0
  87. txt_but_apply db 'Apply',0
  88. txt_but_create db 'Create',0
  89. txt_size_x db 'size x: ',0
  90. txt_size_y db 'size y: ',0
  91. txt_poi_sel: db 'Select points: '
  92. .end db 0
  93. txt_err_save_txt_file_0:
  94. txt_err_save_txt_file_1:
  95.         db 'Can',39,'t save *.nc file.',0
  96. txt_err_save_img_file:
  97.         db 'Can',39,'t save *.png file.',0
  98. txt_obj: db 'Object: ',39
  99. .end db 0
  100. end if
  101.  
  102. align 4
  103. txt_s_39 db 39,' ',0
  104. txt_s_poi db 'X',0
  105. txt_s_poi_Y db ' Y',0
  106. txt_s_poi_Z db ' Z',0
  107. txt_coma db ','
  108. txt_space db ' ',0 ;­¥ ®âà뢠âì ®â § ¯ï⮩
  109. txt_nl db 13,10,0
  110. txt_n db 13,0
  111. txt_ls db ' (',0
  112. txt_rs db ')',0
  113. txt_len db ' len=',0
  114. txt_39 db 39,0
  115.  
  116. use_mem_array_figure equ 0 ;1 - ¨á¯®«ì§®¢ âì ¤¨­ ¬¨ç¥áª¨© ¬ áᨢ ¤«ï áâàãªâãà á ®¯¨á ­¨ï¬¨ 䨣ãà
  117.  
  118. ;᢮©á⢠ ¤«ï à¨á®¢ ­¨ï â®ç¥ª
  119. PROP_BIT_SELECT    equ 30 ;â®çª  ¯®¤ ¢ë¤¥«¥­¨¥¬
  120.  
  121. align 4
  122. zoom_plus dq 1.25992105
  123. mouse_prop_x dd 0 ;ªãàá®à ¬ëè¨ ®â­®á¨â¥«ì­® 業âà  ®ª­  buf_0 (¤«ï ¨§¬¥­. ¬ áèâ ¡ )
  124. mouse_prop_y dd 0
  125. mouse_down_x dd 0 ;ªãàá®à ¬ëè¨ ®â­®á¨â¥«ì­® «¥¢®£® ¢¥àå­¥£® 㣫  ®ª­  buf_0 (¤«ï ᤢ¨£  䨣ãàë)
  126. mouse_down_y dd 0
  127. opt_draw  dd 1
  128. graf_margin_left   dd 3 ;margin in pixels
  129. graf_margin_right  dd 3+6 ;margin in pixels
  130. graf_margin_top    dd 3+9 ;margin in pixels
  131. graf_margin_bot    dd 3+9 ;margin in pixels
  132. png_data dd ?
  133. png_size dd ?
  134.  
  135. ;global variables:
  136. ObjData Object
  137. FigData Figure ;¢à¥¬¥­­ ï áâàãªâãà  ¤«ï § ¯®«­¥­¨ï tree1
  138. PoiData Point
  139.  
  140. size_one_list equ sizeof.Figure ;max (sizeof.Figure, sizeof.Object)
  141.  
  142. if sizeof.Object > sizeof.Figure
  143.    ... need fix size_one_list
  144. end if
  145.  
  146. if (Object.FigCount <> Figure.PoiCount) | (Object.FigData <> Figure.PoiData) | (Object.MScale <> Figure.MScale) | (Object.MCentrX <> Figure.MCentrX) | (Object.MCentrY <> Figure.MCentrY)
  147.    ... need fix offsets
  148. end if
  149.        
  150. align 4
  151. Scale1mm dq 11.81102362204724 ;pixels in 1 mm -> 300 dpi
  152.         ;5.905511811023622 ;pixels in 1 mm -> 150 dpi
  153.  
  154. txt_buf rb 80 ;???
  155. txt_sp db ' ',0
  156.  
  157. ;input:
  158. ; esi - text pointer
  159. align 4
  160. proc txt_next_line uses eax ecx edi, mlen:dword
  161.         mov al,13
  162.         mov ecx,[mlen]
  163.         mov edi,esi
  164.         repne scasb
  165.         cmp byte[edi],10
  166.         jne @f
  167.                 inc edi
  168.         @@:
  169.         mov esi,edi
  170.         ret
  171. endp
  172.  
  173. ;input:
  174. ; edi - destination buffer
  175. ; esi - source text string: '...\nl
  176. ; mlen - maximum len destination buffer
  177. align 4
  178. proc txt_load_line uses eax ebx ecx esi, mlen:dword
  179.         mov byte[edi],0
  180.         mov al,13
  181.         cmp byte[esi],al
  182.         je .end_f
  183.                 mov ecx,[mlen]
  184.                 mov ebx,edi
  185.                 mov edi,esi
  186.                 repne scasb ;found end of string
  187.                 mov ecx,edi
  188.                 sub ecx,esi
  189.                 dec ecx ;ecx = string len
  190.                 mov edi,ebx
  191.                 rep movsb ;copy caption string
  192.                 cmp byte[esi],13
  193.                 je @f
  194.                 .cycle0:
  195.                         inc esi
  196.                         cmp byte[esi],13
  197.                         jne .cycle0
  198.                 @@:
  199.                 mov byte[edi],0
  200.                 inc esi
  201.         .end_f:
  202.         ret
  203. endp
  204.  
  205. ;input:
  206. ; itxt - input description text
  207. ; msize - max size
  208. align 4
  209. proc FileInit uses eax ebx ecx edi esi, itxt:dword, msize:dword
  210.         stdcall [tl_node_poi_get_info], tree1,0
  211.         or eax,eax
  212.         jz @f
  213.                 mov ebx,eax
  214.                 stdcall [tl_node_poi_get_data], tree1,ebx
  215.                 stdcall clear_object_in_list, eax
  216.         @@:
  217.         stdcall [tl_info_clear], tree1 ;®ç¨á⪠ ᯨ᪠ ®¡ê¥ªâ®¢
  218.         mov dword[offs_last_timer],0
  219.  
  220.         mov esi,[itxt]
  221.         mov ebx,esi
  222.         add ebx,[msize]
  223.         stdcall ObjectInit,ObjData,ebx
  224.         stdcall [tl_cur_beg], tree1
  225.         ret
  226. endp
  227.  
  228. ;input:
  229. ; esi - input description text
  230. ; pobj - pointer to object struct
  231. ; etxt - pointer to end of input text
  232. align 4
  233. proc ObjectInit uses eax ebx ecx edi, pobj:dword, etxt:dword
  234.                 mov ebx,[pobj]
  235.                 mov [ebx+Object.OType],'Obj'
  236.                 mov edi,ebx
  237.                 add edi,Object.Caption
  238.                 mov dword[edi],'CNC'
  239.  
  240.                 stdcall get_max_lines
  241.                 test eax,eax
  242.                 jz .err_init
  243.                 mov [ebx+Object.FigCount],eax
  244.                 mov ecx,eax
  245.  
  246.                 shl eax,2
  247.                 stdcall mem.Alloc,eax
  248.                 mov [ebx+Object.FigData],eax
  249.                 push ecx
  250.                         mov edi,eax
  251.                         xor eax,eax
  252.                         rep stosd ;clear memory
  253.                 pop ecx
  254.  
  255.                 stdcall add_object_in_list,0,0,ebx,0
  256.                 ;eax -> pointer to object node
  257.                 mov edi,[ebx+Object.FigData]
  258. align 4
  259.                 .cycle0:
  260.                         stdcall FigureInit,FigData,edi
  261.                         cmp esi,[etxt]
  262.                         jge .cycle0end
  263.                         add edi,4
  264.                 loop .cycle0
  265.                 .cycle0end:
  266.                 inc dword[ebx+Object.FigCount] ;???
  267.                 or ecx,ecx
  268.                 jz @f
  269.                         ;㬥­ìè ¥¬ ®¡ê¥¬ ¯ ¬ï⨠¢ë¤¥«¥­­ë© ¤«ï ª®¬ ­¤
  270.                         sub [ebx+Object.FigCount],ecx
  271.                         mov eax,[ebx+Object.FigCount]
  272.                         shl eax,2
  273.                         stdcall mem.ReAlloc,[ebx+Object.FigData],eax
  274.                         mov [ebx+Object.FigData],eax
  275.                 @@:
  276.  
  277.                 stdcall ObjCalculateScale,ebx
  278.  
  279.                 jmp .end_f
  280.         .err_init:
  281.                 notify_window_run txt_err_1
  282.         .end_f:
  283.         ret
  284. endp
  285.  
  286. align 4
  287. proc ObjCalculateScale uses eax ebx ecx edi, pobj:dword
  288.         mov ebx,[pobj]
  289.  
  290.         ;*** Calculate scale for object ***
  291.         finit
  292.  
  293.         ;found min coord X
  294.         mov ecx,[ebx+Object.FigCount]
  295.         jecxz .cycle2end
  296.         mov edi,[ebx+Object.FigData]
  297.         push edi esi ;copy first min X
  298.                 @@:
  299.                         mov eax,[edi]
  300.                         dec ecx
  301.                         jecxz .cycle2end
  302.                         add edi,4
  303.                         or eax,eax
  304.                         jz @b
  305.                         cmp [eax+Figure.PoiCount],0
  306.                         je @b
  307.                 lea esi,[eax+Figure.MinX]
  308.                 lea edi,[ebx+Object.MinX]
  309.                 movsd
  310.                 movsd
  311.         pop esi edi
  312. align 4
  313.         .cycle2:
  314.                 mov eax,[edi]
  315.                 or eax,eax
  316.                 jz @f
  317.                 cmp [eax+Figure.PoiCount],0
  318.                 je @f
  319.                 fld qword[eax+Figure.MinX]
  320.                 fcomp qword[ebx+Object.MinX]
  321.                 fstsw ax
  322.                 sahf
  323.                 ja @f
  324.                         push edi esi
  325.                         mov eax,[edi]
  326.                         lea esi,[eax+Figure.MinX]
  327.                         lea edi,[ebx+Object.MinX]
  328.                         movsd
  329.                         movsd
  330.                         pop esi edi
  331.                 @@:
  332.                 add edi,4
  333.         loop .cycle2
  334.         .cycle2end:
  335.  
  336.         ;found min coord Y
  337.         mov ecx,[ebx+Object.FigCount]
  338.         jecxz .cycle3end
  339.         mov edi,[ebx+Object.FigData]
  340.         push edi esi ;copy first min Y
  341.                 @@:
  342.                         mov eax,[edi]
  343.                         dec ecx
  344.                         jecxz .cycle3end
  345.                         add edi,4
  346.                         or eax,eax
  347.                         jz @b
  348.                         cmp [eax+Figure.PoiCount],0
  349.                         je @b
  350.                 lea esi,[eax+Figure.MinY]
  351.                 lea edi,[ebx+Object.MinY]
  352.                 movsd
  353.                 movsd
  354.         pop esi edi
  355. align 4
  356.         .cycle3:
  357.                 mov eax,[edi]
  358.                 or eax,eax
  359.                 jz @f
  360.                 cmp [eax+Figure.PoiCount],0
  361.                 je @f
  362.                 fld qword[eax+Figure.MinY]
  363.                 fcomp qword[ebx+Object.MinY]
  364.                 fstsw ax
  365.                 sahf
  366.                 ja @f
  367.                         push edi esi
  368.                         mov eax,[edi]
  369.                         lea esi,[eax+Figure.MinY]
  370.                         lea edi,[ebx+Object.MinY]
  371.                         movsd
  372.                         movsd
  373.                         pop esi edi
  374.                 @@:
  375.                 add edi,4
  376.         loop .cycle3
  377.         .cycle3end:
  378.  
  379.         ;found max coord X
  380.         mov ecx,[ebx+Object.FigCount]
  381.         jecxz .cycle4end
  382.         mov edi,[ebx+Object.FigData]
  383.         ;copy first min X
  384.         mov eax,[edi]
  385.         fld qword[eax+Figure.MinX]
  386.         fadd qword[eax+Figure.SizeX]
  387.         fstp qword[ebx+Object.SizeX]
  388.         dec ecx
  389.         jecxz .cycle4end
  390. align 4
  391.         .cycle4:
  392.                 add edi,4
  393.                 mov eax,[edi]
  394.                 or eax,eax
  395.                 jz @f
  396.                 cmp [eax+Figure.PoiCount],0
  397.                 je @f
  398.                 fld qword[eax+Figure.MinX]
  399.                 fadd qword[eax+Figure.SizeX]
  400.                 fcomp qword[ebx+Object.SizeX]
  401.                 fstsw ax
  402.                 sahf
  403.                 jbe @f
  404.                         mov eax,[edi]
  405.                         fld qword[eax+Figure.MinX]
  406.                         fadd qword[eax+Figure.SizeX]
  407.                         fstp qword[ebx+Object.SizeX]
  408.                 @@:
  409.         loop .cycle4
  410.         .cycle4end:
  411.  
  412.         ;found max coord Y
  413.         mov ecx,[ebx+Object.FigCount]
  414.         jecxz .cycle5end
  415.         mov edi,[ebx+Object.FigData]
  416.         ;copy first min Y
  417.         mov eax,[edi]
  418.         fld qword[eax+Figure.MinY]
  419.         fadd qword[eax+Figure.SizeY]
  420.         fstp qword[ebx+Object.SizeY]
  421.         dec ecx
  422.         jecxz .cycle5end
  423. align 4
  424.         .cycle5:
  425.                 add edi,4
  426.                 mov eax,[edi]
  427.                 or eax,eax
  428.                 jz @f
  429.                 cmp [eax+Figure.PoiCount],0
  430.                 je @f
  431.                 fld qword[eax+Figure.MinY]
  432.                 fadd qword[eax+Figure.SizeY]
  433.                 fcomp qword[ebx+Object.SizeY]
  434.                 fstsw ax
  435.                 sahf
  436.                 jbe @f
  437.                         mov eax,[edi]
  438.                         fld qword[eax+Figure.MinY]
  439.                         fadd qword[eax+Figure.SizeY]
  440.                         fstp qword[ebx+Object.SizeY]
  441.                 @@:
  442.         loop .cycle5
  443.         .cycle5end:
  444.  
  445.         ;found size X
  446.         fld qword[ebx+Object.SizeX]
  447.         fsub qword[ebx+Object.MinX]
  448.         fstp qword[ebx+Object.SizeX]
  449.         ;found size Y
  450.         fld qword[ebx+Object.SizeY]
  451.         fsub qword[ebx+Object.MinY]
  452.         fstp qword[ebx+Object.SizeY]
  453.  
  454.         ;*** Calculate scale ***
  455.                 fld1
  456.                 fstp qword[ebx+Object.WScale] ;set default scale
  457.  
  458.                 fld qword[ebx+Object.SizeX]
  459.                 ftst
  460.                 fstsw ax
  461.                 sahf
  462.                 jne .els_0 ;if (SizeX == 0.0)
  463.                         ffree st0
  464.                         fincstp
  465.                         jmp .els_1
  466.                 .els_0: ;else if (SizeX != 0.0)
  467.                         fild dword[buf_0.w]
  468.                         fisub dword[graf_margin_left]
  469.                         fisub dword[graf_margin_right]
  470.                         fxch st1
  471.                         fdivp
  472.                         fstp qword[ebx+Object.WScale]
  473.                 .els_1:
  474.  
  475.                 fld qword[ebx+Object.SizeY]
  476.                 ftst
  477.                 fstsw ax
  478.                 sahf
  479.                 jne .els_2 ;if (SizeY == 0.0)
  480.                         ffree st0
  481.                         fincstp
  482.                         jmp .els_3
  483.                 .els_2: ;else if (SizeY != 0.0)
  484.                         fild dword[buf_0.h]
  485.                         fisub dword[graf_margin_top]
  486.                         fisub dword[graf_margin_bot]
  487.                         fxch st1
  488.                         fdivp
  489.                         fcom qword[ebx+Object.WScale]
  490.                         fstsw ax
  491.                         sahf
  492.                         jbe @f
  493.                                 ffree st0
  494.                                 fincstp
  495.                                 jmp .els_3
  496.                         @@:
  497.                         fstp qword[ebx+Object.WScale]
  498.                 .els_3:
  499.  
  500.                 fld1
  501.                 fstp qword[ebx+Figure.MScale]
  502.                 mov dword[ebx+Figure.MCentrX],0
  503.                 mov dword[ebx+Figure.MCentrY],0
  504.         ret
  505. endp
  506.  
  507. ;input:
  508. ; esi - input description text
  509. ; pmem - pointer to memory for struct
  510. ; pfig - pointer to figure struct
  511. ;output:
  512. ; esi - output description text
  513. align 4
  514. proc FigureInit uses eax ebx ecx edx edi, pmem:dword, pfig:dword
  515.         mov ebx,[pmem]
  516.         mov [ebx+Figure.OType],'Fig'
  517.         mov edi,ebx
  518.         add edi,Figure.Caption
  519.         stdcall txt_load_line,32
  520.                
  521.         xor eax,eax
  522.         mov [ebx+Figure.PoiCount],eax
  523.         mov [ebx+Figure.PoiData],eax
  524.         cmp byte[esi],'X'
  525.         jne .end0
  526.                 stdcall get_max_points
  527.                 mov [ebx+Figure.PoiCount],eax
  528.                 or eax,eax
  529.                 jz .end0
  530.                 mov ecx,eax
  531.                 imul eax,sizeof.Point
  532.                 stdcall mem.Alloc,eax
  533.                 mov [ebx+Figure.PoiData],eax
  534.                 or eax,eax
  535.                 jz .err_init
  536.                 mov edi,eax
  537. align 4
  538.                 .cycle0:
  539.                         stdcall PointInit,edi
  540.                         or eax,eax
  541.                         jz .cycle0end
  542.                         add edi,sizeof.Point
  543.                         loop .cycle0
  544.                 .cycle0end:
  545.                 or ecx,ecx
  546.                 jz .end1
  547.                         ;㬥­ìè ¥¬ ®¡ê¥¬ ¯ ¬ï⨠¢ë¤¥«¥­­ë© ¤«ï â®ç¥ª
  548.                         sub [ebx+Figure.PoiCount],ecx
  549.                         mov eax,[ebx+Figure.PoiCount]
  550.                         imul eax,sizeof.Point
  551.                         stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
  552.                         mov [ebx+Figure.PoiData],eax
  553.                 jmp .end1
  554.         .err_init:
  555.                 notify_window_run txt_err_2
  556.         .end0:
  557.                 ;command
  558.                 stdcall txt_next_line, 80
  559.                 cmp byte[esi],13
  560.                 jne @f
  561.                         ;if null line
  562.                         inc esi
  563.                         cmp byte[esi],10
  564.                         jne .end2
  565.                                 inc esi
  566.                         .end2:
  567.                         mov dword[edi],(10 shl 8)+13 ;new line
  568.                 @@:
  569.                 stdcall add_object_in_list,1,1,ebx,[pfig]
  570.                 jmp .end_f
  571.         .end1:
  572.                 ;coords
  573.                 stdcall add_object_in_list,2,1,ebx,[pfig]
  574.                 or eax,eax
  575.                 jz .end_f
  576.                 stdcall FigCalculateSizes,eax,1
  577.         .end_f:
  578.         ret
  579. endp
  580.  
  581. ;input:
  582. ; esi - pointer to file
  583. ;output:
  584. ; eax - max lines in file
  585. align 4
  586. proc get_max_lines uses esi
  587.         xor eax,eax
  588.         .cycle0:
  589.                 cmp byte[esi],13
  590.                 jne @f
  591.                         inc eax
  592.                 @@:
  593.                 inc esi
  594.                 cmp byte[esi],0
  595.                 jne .cycle0
  596.         ret
  597. endp
  598.  
  599. ;input:
  600. ; esi - pointer to file
  601. ;output:
  602. ; eax - max point coords in file
  603. align 4
  604. proc get_max_points uses esi
  605.         xor eax,eax
  606.         .cycle0:
  607.                 cmp word[esi],' Y'
  608.                 jne @f
  609.                         inc eax
  610.                 @@:
  611.                 inc esi
  612.                 cmp byte[esi+1],0
  613.                 jne .cycle0
  614.         ret
  615. endp
  616.  
  617. ;input:
  618. ; opt_calc - ¥á«¨ 0 - ¯¥à¥áç¨â âì ¬ áèâ ¡ 䨣ãàë,
  619. ;                 1 - ¯¥à¥áç¨â âì à §¬¥àë ¨ ¬ áèâ ¡ 䨣ãàë
  620. align 4
  621. proc FigCalculateSizes uses eax ebx ecx edi esi, pfig:dword, opt_calc:dword
  622.         mov ebx,[pfig]
  623.         or ebx,ebx
  624.         jz .end_f
  625.  
  626.         finit
  627.         bt dword[opt_calc],0
  628.         jnc .calc_scale
  629.  
  630.         ;*** Calculate sizes ***
  631.         mov esi,[ebx+Figure.PoiData]
  632.         or esi,esi
  633.         jz .end_f
  634.  
  635.         lea esi,[esi+Point.CoordX]
  636.         lea edi,[ebx+Figure.MinX]
  637.         movsd
  638.         movsd ;Figure.MinX = Point[0].CoordX
  639.         sub esi,8
  640.         lea edi,[ebx+Figure.SizeX]
  641.         movsd
  642.         movsd ;Figure.SizeX = Point[0].CoordX
  643.         mov esi,[ebx+Figure.PoiData]
  644.         lea esi,[esi+Point.CoordY]
  645.         lea edi,[ebx+Figure.MinY]
  646.         movsd
  647.         movsd ;Figure.MinY = Point[0].CoordY
  648.         sub esi,8
  649.         lea edi,[ebx+Figure.SizeY]
  650.         movsd
  651.         movsd ;Figure.SizeY = Point[0].CoordY
  652.  
  653.         ;found min coord X
  654.         mov ecx,[ebx+Figure.PoiCount]
  655.         jecxz .cycle2end
  656.         mov edi,[ebx+Figure.PoiData]
  657. align 4
  658.         .cycle2:
  659.                 fld qword[edi+Point.CoordX]
  660.                 fcomp qword[ebx+Figure.MinX]
  661.                 fstsw ax
  662.                 sahf
  663.                 ja @f
  664.                         push edi esi
  665.                         lea esi,[edi+Point.CoordX]
  666.                         lea edi,[ebx+Figure.MinX]
  667.                         movsd
  668.                         movsd
  669.                         pop esi edi
  670.                 @@:
  671.                 add edi,sizeof.Point
  672.         loop .cycle2
  673.         .cycle2end:
  674.  
  675.         ;found min coord Y
  676.         mov ecx,[ebx+Figure.PoiCount]
  677.         jecxz .cycle3end
  678.         mov edi,[ebx+Figure.PoiData]
  679. align 4
  680.         .cycle3:
  681.                 fld qword[edi+Point.CoordY]
  682.                 fcomp qword[ebx+Figure.MinY]
  683.                 fstsw ax
  684.                 sahf
  685.                 ja @f
  686.                         push edi esi
  687.                         lea esi,[edi+Point.CoordY]
  688.                         lea edi,[ebx+Figure.MinY]
  689.                         movsd
  690.                         movsd
  691.                         pop esi edi
  692.                 @@:
  693.                 add edi,sizeof.Point
  694.         loop .cycle3
  695.         .cycle3end:
  696.  
  697.         ;found max coord X
  698.         mov ecx,[ebx+Figure.PoiCount]
  699.         jecxz .cycle4end
  700.         mov edi,[ebx+Figure.PoiData]
  701. align 4
  702.         .cycle4:
  703.                 fld qword[edi+Point.CoordX]
  704.                 fcomp qword[ebx+Figure.SizeX]
  705.                 fstsw ax
  706.                 sahf
  707.                 jbe @f
  708.                         push edi esi
  709.                         lea esi,[edi+Point.CoordX]
  710.                         lea edi,[ebx+Figure.SizeX]
  711.                         movsd
  712.                         movsd
  713.                         pop esi edi
  714.                 @@:
  715.                 add edi,sizeof.Point
  716.         loop .cycle4
  717.         .cycle4end:
  718.  
  719.         ;found max coord Y
  720.         mov ecx,[ebx+Figure.PoiCount]
  721.         jecxz .cycle5end
  722.         mov edi,[ebx+Figure.PoiData]
  723. align 4
  724.         .cycle5:
  725.                 fld qword[edi+Point.CoordY]
  726.                 fcomp qword[ebx+Figure.SizeY]
  727.                 fstsw ax
  728.                 sahf
  729.                 jbe @f
  730.                         push edi esi
  731.                         lea esi,[edi+Point.CoordY]
  732.                         lea edi,[ebx+Figure.SizeY]
  733.                         movsd
  734.                         movsd
  735.                         pop esi edi
  736.                 @@:
  737.                 add edi,sizeof.Point
  738.         loop .cycle5
  739.         .cycle5end:
  740.  
  741.         ;found size X
  742.         fld qword[ebx+Figure.SizeX]
  743.         fsub qword[ebx+Figure.MinX]
  744.         fstp qword[ebx+Figure.SizeX]
  745.         ;found size Y
  746.         fld qword[ebx+Figure.SizeY]
  747.         fsub qword[ebx+Figure.MinY]
  748.         fstp qword[ebx+Figure.SizeY]
  749.                
  750.         ;*** Calculate scale ***
  751. align 4
  752.         .calc_scale:
  753.         mov dword[ebx+Figure.MCentrX],0
  754.         mov dword[ebx+Figure.MCentrY],0
  755.         fld1
  756.         fst qword[ebx+Figure.MScale] ;???
  757.         fstp qword[ebx+Figure.WScale] ;set default scale
  758.  
  759.         fld qword[ebx+Figure.SizeX]
  760.         ftst
  761.         fstsw ax
  762.         sahf
  763.         jne .els_0 ;if (SizeX == 0.0)
  764.                 ffree st0
  765.                 fincstp
  766.                 jmp .els_1
  767.         .els_0: ;else if (SizeX != 0.0)
  768.                 fild dword[buf_0.w]
  769.                 fisub dword[graf_margin_left]
  770.                 fisub dword[graf_margin_right]
  771.                 fxch st1
  772.                 fdivp
  773.                 fstp qword[ebx+Figure.WScale]
  774.         .els_1:
  775.  
  776.         fld qword[ebx+Figure.SizeY]
  777.         ftst
  778.         fstsw ax
  779.         sahf
  780.         jne .els_2 ;if (SizeY == 0.0)
  781.                 ffree st0
  782.                 fincstp
  783.                 jmp .els_3
  784.         .els_2: ;else if (SizeY != 0.0)
  785.                 fild dword[buf_0.h]
  786.                 fisub dword[graf_margin_top]
  787.                 fisub dword[graf_margin_bot]
  788.                 fxch st1
  789.                 fdivp
  790.                 fcom qword[ebx+Figure.WScale]
  791.                 fstsw ax
  792.                 sahf
  793.                 jbe @f
  794.                         ffree st0
  795.                         fincstp
  796.                         jmp .els_3
  797.                 @@:
  798.                 fstp qword[ebx+Figure.WScale]
  799.         .els_3:
  800.  
  801.         .end_f:
  802.         ret
  803. endp
  804.  
  805. ;input:
  806. ; esi - input description text
  807. ; ppoi - pointer to point struct
  808. ;output:
  809. ; eax - 0 (if error init) or 1
  810. ; esi - output description text
  811. align 4
  812. proc PointInit uses ebx ecx edi, ppoi:dword
  813.         mov     ecx,64 ;§ é¨â  ®â § æ¨ª«¨¢ ­¨ï
  814.         @@:
  815.                 lodsb
  816.                 cmp     al,' '
  817.                 jne     @f
  818.                 loop @b
  819.         @@:
  820.         dec esi
  821.         cmp byte[esi],'X'
  822.         jne .err_init
  823.                 inc esi
  824.                 stdcall conv_str_to_int, esi
  825.                 mov ebx,[ppoi]
  826.  
  827.                 ;Data_String <- esi
  828.                 push esi
  829.                         mov ecx,32
  830.                         mov edi,esi
  831.                         @@:
  832.                                 lodsb
  833.                                 or al,al
  834.                                 jz @f
  835.                                 cmp al,' '
  836.                                 je @f
  837.                                 cmp al,13
  838.                                 je @f
  839.                                 loop @b
  840.                         @@:
  841.                         mov esi,edi
  842.                         sub ecx,32
  843.                         neg ecx
  844.                         mov edi,Data_String
  845.                         rep movsb
  846.                         mov byte[edi],0
  847.                 pop esi
  848.                 stdcall String_to_DoubleFloat
  849.                 ;Data_Double -> Point.CoordX
  850.                 push esi
  851.                         mov esi,Data_Double
  852.                         lea edi,[ebx+Point.CoordX]
  853.                         movsd
  854.                         movsd
  855.                 pop esi
  856.  
  857.                 push edi
  858.                 mov al,'Y'
  859.                 mov ecx,80
  860.                 mov edi,esi
  861.                 repne scasb
  862.                 mov esi,edi
  863.                 pop edi
  864.                 ;Data_String <- esi
  865.                 push esi
  866.                         mov ecx,32
  867.                         mov edi,esi
  868.                         @@:
  869.                                 lodsb
  870.                                 or al,al
  871.                                 jz @f
  872.                                 cmp al,' '
  873.                                 je @f
  874.                                 cmp al,13
  875.                                 je @f
  876.                                 loop @b
  877.                         @@:
  878.                         mov esi,edi
  879.                         sub ecx,32
  880.                         neg ecx
  881.                         mov edi,Data_String
  882.                         rep movsb
  883.                         mov byte[edi],0
  884.                 pop esi
  885.                 stdcall String_to_DoubleFloat
  886.                 ;Data_Double -> Point.CoordY
  887.                 push esi
  888.                         mov esi,Data_Double
  889.                         lea edi,[ebx+Point.CoordY]
  890.                         movsd
  891.                         movsd
  892.                 pop esi
  893.  
  894.                 stdcall txt_next_line, 80
  895.                 jmp @f
  896.         .err_init:
  897.                 xor eax,eax
  898.                 jmp .end_f
  899.         @@:
  900.                 xor eax,eax
  901.                 inc eax
  902.         .end_f:
  903.         ret
  904. endp
  905.  
  906. ;input:
  907. ; icon - ­®¬¥à ¨ª®­ª¨
  908. ; level - ã஢¥­ì ¢«®¦¥­­®á⨠㧫 
  909. ; buffer - ¤®¡ ¢«ï¥¬ë¥ ¤ ­­ë¥
  910. ; pfig - 㪠§ â¥«ì ­  ¤®¡ ¢«¥­­ãî 䨣ãàã (¤«ï ª®­â஫ï á® áâ®à®­ë த¨â¥«ì᪮£® ®¡ê¥ªâ )
  911. ;output:
  912. ; eax - object data pointer
  913. align 4
  914. proc add_object_in_list uses ebx, icon:dword,level:dword,buffer:dword, pfig:dword
  915.         mov ax,word[icon]
  916.         shl eax,16
  917.         mov ax,word[level]
  918.  
  919.         stdcall [tl_node_add], tree1, eax, [buffer]
  920.         stdcall [tl_node_get_data],tree1
  921.         mov ebx,[pfig]
  922.         or ebx,ebx
  923.         jz @f
  924.                 mov [ebx],eax
  925.         @@:
  926.         stdcall [tl_cur_next], tree1
  927.         ret
  928. endp
  929.  
  930. align 4
  931. proc clear_object_in_list uses eax, buffer:dword
  932.         mov eax,[buffer]
  933.         cmp dword[eax+Object.FigCount],0 ;or Figure.PoiCount
  934.         je .end_f
  935.                 stdcall mem.Free,[eax+Object.FigData] ;or Figure.PoiData
  936.         .end_f:
  937.         ret
  938. endp
  939.  
  940. ;description:
  941. ; äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï ¢ë¡à ­­®£® ®¡ê¥ªâ 
  942. align 4
  943. proc draw_obj2d, pobj:dword
  944. locals
  945.         CentrX dd ?
  946.         CentrY dd ?
  947. endl
  948. pushad
  949.         mov ebx,[pobj]
  950.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  951.         mov ecx,[ebx+Object.FigCount]
  952.         or ecx,ecx
  953.         jz .end_f
  954.         ;;jecxz .end_f
  955.                 mov edi,[ebx+Object.FigData]
  956.                 finit
  957.                 fld qword[ebx+Object.SizeY]
  958.                 fmul qword[ebx+Object.WScale]
  959.                 fmul qword[ebx+Object.MScale]
  960.                 fchs
  961.                 fistp dword[CentrY]
  962.                 mov eax,[CentrY]
  963.                 sub eax,[graf_margin_top]
  964.                 sub eax,[graf_margin_bot]
  965.                 add eax,[buf_0.h]
  966.                 sar eax,1
  967.                 add eax,[graf_margin_bot] ;_bot   ­¥ _top - ¢ á¢ï§¨ á ⥬ çâ® ª®®à¤. Y ¯¥à¥¢¥à­ãâ 
  968.                 add eax,[ebx+Object.MCentrY]
  969.                 mov [CentrY],eax
  970.                 fld qword[ebx+Object.SizeX]
  971.                 fmul qword[ebx+Object.WScale]
  972.                 fmul qword[ebx+Object.MScale]
  973.                 fchs
  974.                 fistp dword[CentrX]
  975.                 mov edx,[CentrX]
  976.                 sub edx,[graf_margin_left]
  977.                 sub edx,[graf_margin_right]
  978.                 add edx,[buf_0.w]
  979.                 sar edx,1
  980.                 add edx,[graf_margin_left]
  981.                 add edx,[ebx+Object.MCentrX]
  982.                 mov [CentrX],edx
  983. align 4
  984.                 .cycle0:
  985.                         stdcall draw_fig2d_litl, buf_0,ebx,[edi],0,edx,eax
  986.                         add edi,4
  987.                         loop .cycle0
  988.                 stdcall [buf2d_flip_v], buf_0
  989.  
  990.         bt dword[opt_draw],0
  991.         jnc .end_f
  992.                 ; draw min & sizes
  993.                 mov word[NumberSymbolsAD],8
  994.                 stdcall mem_copy, txt_buf,txt_size_x,20
  995.                 fld qword[ebx+Object.SizeX]
  996.                 fstp qword[Data_Double]
  997.                 call DoubleFloat_to_String
  998.                 call String_crop_0
  999.                 stdcall str_cat,txt_buf,Data_String
  1000.                 stdcall str_cat,txt_buf,txt_n
  1001.                 stdcall str_cat,txt_buf,txt_size_y
  1002.                 fld qword[ebx+Object.SizeY]
  1003.                 fstp qword[Data_Double]
  1004.                 call DoubleFloat_to_String
  1005.                 call String_crop_0
  1006.                 stdcall str_cat,txt_buf,Data_String
  1007.                 stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,23,0
  1008.  
  1009.                 fld qword[ebx+Object.MinX]
  1010.                 fstp qword[Data_Double]
  1011.                 stdcall mem_copy, txt_buf,txt_min_x,20
  1012.                 call DoubleFloat_to_String
  1013.                 call String_crop_0
  1014.                 stdcall str_cat,txt_buf,Data_String
  1015.                 stdcall str_cat,txt_buf,txt_n
  1016.                 stdcall str_cat,txt_buf,txt_min_y
  1017.                 fld qword[ebx+Object.MinY]
  1018.                 fstp qword[Data_Double]
  1019.                 call DoubleFloat_to_String
  1020.                 call String_crop_0
  1021.                 stdcall str_cat,txt_buf,Data_String
  1022.                 stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,3,0
  1023.         .end_f:
  1024. popad
  1025.         ret
  1026. endp
  1027.  
  1028. align 4
  1029. proc draw_obj2d_png uses eax ebx ecx edi esi, pobj:dword
  1030.         mov ebx,[pobj]
  1031.         mov ecx,[ebx+Object.FigCount]
  1032.         cmp dword[ebx+Object.FigCount],0
  1033.         or ecx,ecx
  1034.         jz .end_f
  1035.         ;;jecxz .end_f
  1036.                 mov edi,[ebx+Object.FigData]
  1037.                 stdcall [buf2d_delete], buf_png
  1038.                 finit
  1039.                 fld qword[ebx+Object.SizeY]
  1040.                 fmul qword[Scale1mm]
  1041.                 fiadd dword[graf_margin_top]
  1042.                 fiadd dword[graf_margin_bot]
  1043.                 fistp dword[buf_png.h]
  1044.                 fld qword[ebx+Object.SizeX]
  1045.                 fmul qword[Scale1mm]
  1046.                 fiadd dword[graf_margin_left]
  1047.                 fiadd dword[graf_margin_right]
  1048.                 fistp dword[buf_png.w]
  1049.                 stdcall [buf2d_create], buf_png
  1050. align 4
  1051.                 .cycle0:
  1052.                         stdcall draw_fig2d_litl, buf_png,ebx,[edi],Scale1mm,[graf_margin_left],[graf_margin_bot] ;_bot   ­¥ _top - ¢ á¢ï§¨ á ⥬ çâ® ª®®à¤. Y ¯¥à¥¢¥à­ãâ 
  1053.                         add edi,4
  1054.                         loop .cycle0
  1055.                 stdcall [buf2d_flip_v], buf_png
  1056.         .end_f:
  1057.         ret
  1058. endp
  1059.  
  1060. ;input:
  1061. ; pbuf - pointer to buffer 2d
  1062. ;description:
  1063. ; äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï ®¡ê¥ªâ  ¯® ç áâï¬
  1064. align 4
  1065. proc draw_fig2d_litl, pbuf:dword, pobj:dword, pfig:dword, Scale:dword, CentrX:dword, CentrY:dword
  1066. locals
  1067.         PervX dd 0 ;pervios point coord X
  1068.         PervY dd 0 ;pervios point coord Y
  1069.         GrafX dd ? ;active point coord X
  1070.         GrafY dd ? ;active point coord Y
  1071. endl
  1072. pushad
  1073.         mov ebx,[pfig]
  1074.         test ebx,ebx
  1075.         jz .end_f
  1076.         mov ecx,[ebx+Figure.PoiCount]
  1077.         ;;jecxz .end_f
  1078.         test ecx,ecx
  1079.         jz .end_f
  1080.         mov edi,[ebx+Figure.PoiData]
  1081.         mov edx,[pobj]
  1082.  
  1083.         fld1
  1084.         mov eax,[Scale]
  1085.         or eax,eax
  1086.         jnz @f
  1087.                 lea eax,[edx+Object.MScale]
  1088.                 fmul qword[eax]
  1089.                 lea eax,[edx+Object.WScale]
  1090.         @@:
  1091.         fmul qword[eax]
  1092. align 4
  1093.         .cycle0:
  1094.                 fld qword[edi+Point.CoordX]
  1095.                 fsub qword[edx+Object.MinX]
  1096.                 fmul st0,st1
  1097.                 fiadd dword[CentrX]
  1098.                 fistp dword[ebp-8]
  1099.                 fld qword[edi+Point.CoordY]
  1100.                 fsub qword[edx+Object.MinY]
  1101.                 fmul st0,st1
  1102.                 fiadd dword[CentrY]
  1103.                 fistp dword[ebp-4]
  1104.                 stdcall [buf2d_set_pixel], [pbuf], [GrafX],[GrafY], 0xff0000
  1105.                 cmp ecx,[ebx+Figure.PoiCount]
  1106.                 je @f
  1107.                         stdcall [buf2d_line_sm], [pbuf], [PervX],[PervY], [GrafX],[GrafY], 0x80
  1108.                         ;sub esp,24
  1109.                         ;call [buf2d_line]
  1110.                         stdcall [buf2d_line], [pbuf], [PervX],[PervY], [GrafX],[GrafY], 0x80
  1111.                 @@:
  1112.                 mov eax,[GrafX]
  1113.                 mov [PervX],eax
  1114.                 mov eax,[GrafY]
  1115.                 mov [PervY],eax
  1116.                 add edi,sizeof.Point
  1117.         ;;loop .cycle0
  1118.                 dec ecx
  1119.         jnz .cycle0
  1120.         ffree st0
  1121.         fincstp
  1122.  
  1123.         .end_f:
  1124. popad
  1125.         ret
  1126. endp
  1127.  
  1128. ;description:
  1129. ; äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï ¢ë¡à ­­®© 䨣ãàë
  1130. align 4
  1131. proc draw_fig2d, pfig:dword
  1132. locals
  1133.         n dd 0
  1134.         col_lin dd 0 ;梥⠫¨­¨© 䨣ãàë
  1135.         CentrX dd ?
  1136.         CentrY dd ?
  1137.         PervX dd 0 ;pervios point coord X
  1138.         PervY dd 0 ;pervios point coord Y
  1139.         GrafX dd ? ;active point coord X
  1140.         GrafY dd ? ;active point coord Y
  1141.         old_tl dd 0 ;old text coord X0
  1142.         old_tt dd 0 ;old text coord Y0
  1143.         old_tw dd 0 ;old text coord X1
  1144.         old_th dd 0 ;old text coord Y1
  1145.         new_tl dd 0 ;new text coord X0
  1146.         ;new_tt dd 0 ;new text coord Y0
  1147.         new_tw dd 0 ;new text coord X1
  1148.         ;new_th dd 0 ;new text coord Y1
  1149. endl
  1150. pushad
  1151.         stdcall [buf2d_clear], buf_0, [buf_0.color]
  1152.         mov ebx,[pfig]
  1153.         test ebx,ebx
  1154.         jz .end_f
  1155.         mov ecx,[ebx+Figure.PoiCount]
  1156.         ;;jecxz .end_f
  1157.         test ecx,ecx
  1158.         jz .end_f
  1159.         mov edi,[ebx+Figure.PoiData]
  1160.         finit
  1161.         fld qword[ebx+Figure.SizeY]
  1162.         fmul qword[ebx+Figure.WScale]
  1163.         fmul qword[ebx+Figure.MScale]
  1164.         fchs
  1165.         fistp dword[CentrY]
  1166.         mov eax,[CentrY]
  1167.         sub eax,[graf_margin_top]
  1168.         sub eax,[graf_margin_bot]
  1169.         add eax,[buf_0.h]
  1170.         sar eax,1
  1171.         add eax,[graf_margin_bot]
  1172.         add eax,[ebx+Figure.MCentrY]
  1173.         mov [CentrY],eax
  1174.         ;CentrY = (-(Figure.SizeY * Figure.WScale) - graf_margin_top - graf_margin_bot + buf_0.h) / 2 + graf_margin_bot
  1175.         fld qword[ebx+Figure.SizeX]
  1176.         fmul qword[ebx+Figure.WScale]
  1177.         fmul qword[ebx+Figure.MScale]
  1178.         fchs
  1179.         fistp dword[CentrX]
  1180.         mov eax,[CentrX]
  1181.         sub eax,[graf_margin_left]
  1182.         sub eax,[graf_margin_right]
  1183.         add eax,[buf_0.w]
  1184.         sar eax,1
  1185.         add eax,[graf_margin_left]
  1186.         add eax,[ebx+Figure.MCentrX]
  1187.         mov [CentrX],eax       
  1188.         ;CentrX = (-(Figure.SizeX * Figure.WScale) - graf_margin_left - graf_margin_right + buf_0.w) / 2 + graf_margin_left
  1189.  
  1190. align 4
  1191.         .cycle0:
  1192.                 fld qword[edi+Point.CoordX]
  1193.                 fsub qword[ebx+Figure.MinX]
  1194.                 fmul qword[ebx+Figure.WScale]
  1195.                 fmul qword[ebx+Figure.MScale]
  1196.                 fiadd dword[CentrX]
  1197.                 fistp dword[GrafX]
  1198.                 ;GrafX = (Point.CoordX - Figure.MinX) * Figure.WScale + CentrX
  1199.                 fld qword[edi+Point.CoordY]
  1200.                 fsub qword[ebx+Figure.MinY]
  1201.                 fmul qword[ebx+Figure.WScale]
  1202.                 fmul qword[ebx+Figure.MScale]
  1203.                 fiadd dword[CentrY]
  1204.                 fisub dword[buf_0.h] ;invert coord Y
  1205.                 fchs
  1206.                 fistp dword[GrafY]
  1207.                 ;GrafY = -((Point.CoordY - Figure.MinY) * Figure.WScale + CentrY - buf_0.h)
  1208.  
  1209.                 stdcall [buf2d_set_pixel], buf_0, [GrafX],[GrafY], 0xff0000
  1210.                 mov dword[col_lin],0x80
  1211.                 bt dword[edi+Point.Prop],PROP_BIT_SELECT
  1212.                 jnc @f
  1213.                         stdcall [buf2d_circle], buf_0, [GrafX],[GrafY], 3, 0xff0000
  1214.                 @@:
  1215.                 cmp ecx,[ebx+Figure.PoiCount]
  1216.                 je @f
  1217.                         stdcall [buf2d_line_sm], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin]
  1218.                         stdcall [buf2d_line], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin]
  1219.                 @@:
  1220.                 mov eax,[GrafX]
  1221.                 mov [PervX],eax
  1222.                 mov edx,[GrafY]
  1223.                 mov [PervY],edx
  1224.                 add edi,sizeof.Point
  1225.  
  1226.                 bt dword[opt_draw],0
  1227.                 jnc .end0
  1228.                 ; draw number points
  1229.                 ;mov eax,[GrafX]
  1230.                 ;mov edx,[GrafY]
  1231.                 add eax,2
  1232.                 add edx,2
  1233.                 push eax edi
  1234.                         mov eax,[n]
  1235.                         mov edi,txt_buf
  1236.                         stdcall convert_int_to_str,20
  1237.                 pop edi eax
  1238.  
  1239.                 inc dword[n]
  1240.                 ;calculate new text coords
  1241.                 mov [new_tl],eax
  1242.                 mov esi,eax
  1243.                 stdcall str_len,txt_buf
  1244.                 imul eax,[buf_1.w]
  1245.                 add eax,esi
  1246.                 mov [new_tw],eax
  1247.                 ;rect compare coords
  1248.                 cmp [old_tl],eax
  1249.                 jg .no_comp
  1250.                 cmp [old_tw],esi
  1251.                 jl .no_comp
  1252.                         ;calculate new text coord Y1
  1253.                         mov esi,edx
  1254.                         add esi,[font_h]
  1255.                 cmp [old_tt],esi
  1256.                 jg .no_comp
  1257.                 cmp [old_th],edx
  1258.                 ;jl .no_comp
  1259.                         ;jmp .end0
  1260.                 jge .end0
  1261.                 .no_comp:
  1262.                         mov eax,[new_tl]
  1263.                         mov [old_tl],eax
  1264.                         mov eax,[new_tw]
  1265.                         mov [old_tw],eax
  1266.                         mov [old_tt],edx
  1267.                         add edx,[font_h]
  1268.                         mov [old_th],edx
  1269.                         stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,[old_tl],[old_tt],0x000000
  1270.                 .end0:
  1271.                 dec ecx
  1272.         jnz .cycle0
  1273.  
  1274.         stdcall sel_points_get_count,[pfig]
  1275.         or eax,eax
  1276.         jz .no_point
  1277.                 stdcall mem_copy, txt_buf,txt_poi_sel,txt_poi_sel.end-txt_poi_sel
  1278.                 mov edi,txt_buf+txt_poi_sel.end-txt_poi_sel
  1279.                 stdcall convert_int_to_str, 20
  1280.                 mov word[NumberSymbolsAD],8
  1281.                 cmp eax,1
  1282.                 jne @f
  1283.                         ;¥á«¨ ¢ë¡à ­  ®¤­  â®çª , â® ¯® ­¥© ¢ë¢®¤ ¡®«¥¥ ¤¥â «ì­®© ¨­ä®à¬ æ¨¨
  1284.                         stdcall sel_points_get_first,[pfig]
  1285.                         stdcall str_cat,txt_buf,txt_ls
  1286.                         fld qword[eax+Point.CoordX]
  1287.                         fstp qword[Data_Double]
  1288.                         call DoubleFloat_to_String
  1289.                         call String_crop_0
  1290.                         stdcall str_cat,txt_buf,Data_String
  1291.                         stdcall str_cat,txt_buf,txt_coma
  1292.                         fld qword[eax+Point.CoordY]
  1293.                         fstp qword[Data_Double]
  1294.                         call DoubleFloat_to_String
  1295.                         call String_crop_0
  1296.                         stdcall str_cat,txt_buf,Data_String
  1297.                         stdcall str_cat,txt_buf,txt_rs
  1298.                         jmp .end1
  1299.                 @@:
  1300.                 cmp eax,2
  1301.                 jne .end1
  1302.                         ;¥á«¨ ¢ë¡à ­® 2 â®çª¨
  1303.                         stdcall sel_points_get_first,[pfig]
  1304.                         fld qword[eax+Point.CoordX]
  1305.                         fld qword[eax+Point.CoordY]
  1306.                         stdcall sel_points_get_last,[pfig]
  1307.                         fsub qword[eax+Point.CoordY]
  1308.                         fmul st0,st0
  1309.                         fxch st1
  1310.                         fsub qword[eax+Point.CoordX]
  1311.                         fmul st0,st0
  1312.                         faddp st1,st0
  1313.                         fsqrt
  1314.                         fstp qword[Data_Double]
  1315.                         call DoubleFloat_to_String
  1316.                         call String_crop_0
  1317.                         stdcall str_cat,txt_buf,txt_len
  1318.                         stdcall str_cat,txt_buf,Data_String
  1319.                 .end1:
  1320.                 stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,3,0
  1321.                 jmp .end_f ;­¥ ¢ë¢®¤¨¬ ¨­ä®à¬ æ¨î ® à §¬¥à å
  1322.         .no_point:
  1323.  
  1324.         bt dword[opt_draw],0
  1325.         jnc .end_f
  1326.                 ; draw min & sizes
  1327.                 mov word[NumberSymbolsAD],8
  1328.                 stdcall mem_copy, txt_buf,txt_size_x,20
  1329.                 fld qword[ebx+Figure.SizeX]
  1330.                 fstp qword[Data_Double]
  1331.                 call DoubleFloat_to_String
  1332.                 call String_crop_0
  1333.                 stdcall str_cat,txt_buf,Data_String
  1334.                 stdcall str_cat,txt_buf,txt_n
  1335.                 stdcall str_cat,txt_buf,txt_size_y
  1336.                 fld qword[ebx+Figure.SizeY]
  1337.                 fstp qword[Data_Double]
  1338.                 call DoubleFloat_to_String
  1339.                 call String_crop_0
  1340.                 stdcall str_cat,txt_buf,Data_String
  1341.                 stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,23,0
  1342.  
  1343.                 fld qword[ebx+Figure.MinX]
  1344.                 fstp qword[Data_Double]
  1345.                 stdcall mem_copy, txt_buf,txt_min_x,20
  1346.                 call DoubleFloat_to_String
  1347.                 call String_crop_0
  1348.                 stdcall str_cat,txt_buf,Data_String
  1349.                 stdcall str_cat,txt_buf,txt_n
  1350.                 stdcall str_cat,txt_buf,txt_min_y
  1351.                 fld qword[ebx+Figure.MinY]
  1352.                 fstp qword[Data_Double]
  1353.                 call DoubleFloat_to_String
  1354.                 call String_crop_0
  1355.                 stdcall str_cat,txt_buf,Data_String
  1356.                 stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,3,0
  1357.         .end_f:
  1358. popad
  1359.         ret
  1360. endp
  1361.  
  1362. ;input:
  1363. ; pnode - 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫 
  1364. align 4
  1365. proc get_object_data, pnode:dword
  1366.         mov ecx,[pnode]
  1367.         cmp [ecx+Object.OType],'Obj'
  1368.         jne .end0
  1369.                 mov ecx,ObjData
  1370.                 jmp .end_f
  1371.         .end0:
  1372.                 xor ecx,ecx
  1373.         .end_f:
  1374.         ret
  1375. endp
  1376.  
  1377. ;input:
  1378. ; pfig - pointer to figure
  1379. ;output:
  1380. ; eax - 㪠§ â¥«ì ­  த¨â¥«ì᪨© ®¡ê¥ªâ ¨«¨ 0 ¥á«¨ ­¥ ­ ©¤¥­®
  1381. ; ecx - ­®¬¥à 䨣ãàë ¢­ãâਠ®¡ê¥ªâ 
  1382. align 4
  1383. proc found_parent_obj uses ebx edx edi, pfig:dword
  1384.         mov eax,ObjData
  1385.         mov edx,[eax+Object.FigCount]
  1386.         or edx,edx
  1387.         jz .cycle1end
  1388.         mov edi,[eax+Object.FigData]
  1389.         xor ecx,ecx
  1390.         .cycle1: ;横« ¯® 䨣ãà ¬
  1391.                 mov ebx,[edi]
  1392.                 cmp ebx,[pfig]
  1393.                 je .end_f ;¥á«¨ ­ ©¤¥­®
  1394.                 add edi,4
  1395.                 inc ecx
  1396.                 dec edx
  1397.                 jnz .cycle1
  1398.         .cycle1end:
  1399.         xor eax,eax
  1400.         .end_f:
  1401.         ret
  1402. endp
  1403.  
  1404. ;description:
  1405. ; áç¨â ¥â ª®««¨ç¥á⢮ ¢ë¤¥«¥­­ëå â®ç¥ª
  1406. align 4
  1407. proc sel_points_get_count uses ebx ecx, pFig:dword
  1408.         xor eax,eax
  1409.         mov ebx,[pFig]
  1410.         mov ecx,[ebx+Figure.PoiCount]
  1411.         or ecx,ecx
  1412.         jz .no_point
  1413.         mov ebx,[ebx+Figure.PoiData]
  1414.         .cycle0:
  1415.                 bt dword[ebx+Point.Prop],PROP_BIT_SELECT
  1416.                 jnc @f
  1417.                         inc eax
  1418.                 @@:
  1419.                 add ebx,sizeof.Point
  1420.                 loop .cycle0
  1421.         .no_point:
  1422.         ret
  1423. endp
  1424.  
  1425. ;description:
  1426. ; ¡¥à¥â 㪠§ â¥«ì ­  ¯¥à¢ãî ¢ë¤¥«¥­­ãî â®çªã
  1427. ;output:
  1428. ; eax - 㪠§ â¥«ì ­  â®çªã ¨«¨ 0 ¥á«¨ ­¥ ¢ë¤¥«¥­­®
  1429. align 4
  1430. proc sel_points_get_first uses ecx, pFig:dword
  1431.         mov eax,[pFig]
  1432.         mov ecx,[eax+Figure.PoiCount]
  1433.         or ecx,ecx
  1434.         jz .no_point
  1435.         mov eax,[eax+Figure.PoiData]
  1436.         .cycle0:
  1437.                 bt dword[eax+Point.Prop],PROP_BIT_SELECT
  1438.                 jc .end_f
  1439.                 add eax,sizeof.Point
  1440.                 loop .cycle0
  1441.         .no_point:
  1442.         xor eax,eax
  1443.         .end_f:
  1444.         ret
  1445. endp
  1446.  
  1447. ;input:
  1448. ; pObj - 㪠§ â¥«ì ­  ®¡ê¥ªâ
  1449. ; FigN - ­®¬¥à ª®¬¬ ­¤ë
  1450. ;description:
  1451. ; ¯¥à¥áç¥â 䨣ãà ¯®á«¥ ®¡­®¢«¥­¨ï ª®®à¤¨­ â â®çª¨
  1452. align 4
  1453. proc figure_update_coords uses eax ecx edx, pObj:dword, FigN:dword
  1454.         mov eax,[pObj]
  1455.         mov ecx,[eax+Object.FigCount]
  1456.         mov eax,[eax+Object.FigData]
  1457.         mov edx,[FigN]
  1458.         cmp ecx,edx
  1459.         jle @f
  1460.                 stdcall FigCalculateSizes,[eax+4*edx],1
  1461.                 stdcall ObjCalculateScale,[pObj]
  1462.         @@:
  1463.         ret
  1464. endp
  1465.  
  1466. ;description:
  1467. ; ¡¥à¥â 㪠§ â¥«ì ­  ¯®á«¥¤­îî ¢ë¤¥«¥­­ãî â®çªã
  1468. align 4
  1469. proc sel_points_get_last uses ebx ecx, pFig:dword
  1470.         mov ebx,[pFig]
  1471.         mov ecx,[ebx+Figure.PoiCount]
  1472.         or ecx,ecx
  1473.         jz .no_point
  1474.         mov eax,ecx
  1475.         dec eax
  1476.         imul eax,sizeof.Point
  1477.         add eax,[ebx+Figure.PoiData]
  1478.         .cycle0:
  1479.                 bt dword[eax+Point.Prop],PROP_BIT_SELECT
  1480.                 jc .end_f
  1481.                 sub eax,sizeof.Point
  1482.                 loop .cycle0
  1483.         .no_point:
  1484.         xor eax,eax
  1485.         .end_f:
  1486.         ret
  1487. endp
  1488.  
  1489. ;description:
  1490. ; á­¨¬ ¥â ¢ë¤¥«¥­¨¥ á â®ç¥ª
  1491. align 4
  1492. proc sel_points_clear uses ebx ecx, pFig:dword
  1493.         mov ebx,[pFig]
  1494.         mov ecx,[ebx+Figure.PoiCount]
  1495.         or ecx,ecx
  1496.         jz .no_point
  1497.         mov ebx,[ebx+Figure.PoiData]
  1498.         .cycle0:
  1499.                 btr dword[ebx+Point.Prop],PROP_BIT_SELECT
  1500.                 add ebx,sizeof.Point
  1501.                 loop .cycle0
  1502.         .no_point:
  1503.         ret
  1504. endp
  1505.  
  1506. ;description:
  1507. ; ¨­¢¥àâ¨àã¥â 㪠§ ­­ë© ¡¨â ¢ ᢮©áâ¢ å ¢ë¤¥«¥­­ëå â®ç¥ª
  1508. align 4
  1509. proc sel_points_invert_bit uses eax ebx ecx, pFig:dword, iBit:dword
  1510.         mov ecx,[iBit]
  1511.         xor eax,eax
  1512.         inc eax
  1513.         shl eax,cl
  1514.         mov ebx,[pFig]
  1515.         mov ecx,[ebx+Figure.PoiCount]
  1516.         or ecx,ecx
  1517.         jz .no_point
  1518.         mov ebx,[ebx+Figure.PoiData]
  1519.         .cycle0:
  1520.                 bt dword[ebx+Point.Prop],PROP_BIT_SELECT
  1521.                 jnc @f
  1522.                         xor dword[ebx+Point.Prop],eax
  1523.                 @@:
  1524.                 add ebx,sizeof.Point
  1525.                 loop .cycle0
  1526.         .no_point:
  1527.         ret
  1528. endp
  1529.  
  1530. ;input:
  1531. ; pPoi - 㪠§ â¥«ì ­  ¤ ­­ë¥ â®çª¨
  1532. align 4
  1533. proc point_move_up, pObj:dword,pFig:dword,idFig:dword,pPoi:dword
  1534. pushad
  1535.         ;¨§¬¥­¥­¨¥ ááë«®ª ­  â®çª¨
  1536.         mov eax,[pObj]
  1537.         mov ecx,[idFig]
  1538.         mov edx,[eax+Object.FigCount]
  1539.         or edx,edx
  1540.         jz .end_f
  1541.         mov edi,[eax+Object.FigData]
  1542.  
  1543.         ;¬¥­ï¥¬ â®çª¨ ¬¥áâ ¬¨
  1544.         mov ecx,sizeof.Point
  1545.         mov esi,[pPoi]
  1546.         sub esi,ecx
  1547.         mov edi,PoiData
  1548.         rep movsb ;p(-1) > p_s
  1549.         mov ecx,sizeof.Point
  1550.         mov edi,[pPoi]
  1551.         sub edi,ecx
  1552.         rep movsb ;p(0) > p(-1)
  1553.         mov esi,PoiData
  1554.         mov ecx,sizeof.Point
  1555.         rep movsb ;p_s > p(0)
  1556.         .end_f:
  1557. popad
  1558.         ret
  1559. endp
  1560.  
  1561. align 4
  1562. proc mouse_left_d uses eax ebx
  1563.         stdcall [tl_node_get_data],tree1
  1564.         or eax,eax
  1565.         jz .end_f
  1566.  
  1567.         cmp [eax+Figure.OType],'Fig'
  1568.         je @f
  1569.         cmp [eax+Figure.OType],'Obj'
  1570.         je .end0
  1571.                 jmp .end_f
  1572.         .end0:
  1573.                 mov eax,ObjData
  1574.         @@:
  1575.         call buf_get_mouse_coord
  1576.         cmp eax,-1
  1577.         je .end_f
  1578.                 mov [mouse_down_x],eax
  1579.                 mov [mouse_down_y],ebx
  1580.         .end_f:
  1581.         ret
  1582. endp
  1583.  
  1584. align 4
  1585. proc mouse_left_u uses eax ebx ecx
  1586.         stdcall [tl_node_get_data],tree1
  1587.         or eax,eax
  1588.         jz .end_f
  1589.  
  1590.         cmp [eax+Figure.OType],'Fig'
  1591.         je @f
  1592.         cmp [eax+Figure.OType],'Obj'
  1593.         je .end0
  1594.                 jmp .end_f
  1595.         .end0:
  1596.                 mov eax,ObjData
  1597.         @@:
  1598.         mov ecx,eax
  1599.  
  1600.         call buf_get_mouse_coord
  1601.         cmp eax,-1
  1602.         je .end_f
  1603.                 sub eax,[mouse_down_x]
  1604.                 sub ebx,[mouse_down_y]
  1605.                 add [ecx+Figure.MCentrX],eax
  1606.                 sub [ecx+Figure.MCentrY],ebx
  1607.                 mov dword[offs_last_timer],0
  1608.         .end_f:
  1609.         ret
  1610. endp
  1611.  
  1612. ;output:
  1613. ; eax, ebx - ¯®àâïâáï
  1614. align 4
  1615. proc mouse_right_d uses ecx edx edi
  1616. locals
  1617.         BufX dd ?
  1618.         BufY dd ?
  1619.         CentrX dd ?
  1620.         CentrY dd ?
  1621.         GrafX dd ? ;active point coord X
  1622.         GrafY dd ? ;active point coord Y
  1623. endl
  1624.         call buf_get_mouse_coord
  1625.         cmp eax,-1
  1626.         je .end_f
  1627.         mov [BufX],eax
  1628.         mov [BufY],ebx
  1629.  
  1630.         ;¯à®á¬ âਢ ¥¬ ¢ë¤¥«¥­­ë© ¡«®ª ¤ ­­ëå
  1631.         stdcall [tl_node_get_data],tree1
  1632.         or eax,eax
  1633.         jz .end_f
  1634.  
  1635.         cmp [eax+Figure.OType],'Fig'
  1636.         jne .end_fblo
  1637.  
  1638.         mov ecx,eax
  1639.         mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS ;¯à®¢¥àª  Shift
  1640.         bt eax,0
  1641.         jc @f
  1642.         bt eax,1
  1643.         jc @f
  1644.                 ;¥á«¨ ­¥ ­ ¦ â Shift
  1645.                 stdcall sel_points_clear,ecx
  1646.         @@:
  1647.         mov ebx,ecx
  1648.         mov ecx,[ebx+Figure.PoiCount]
  1649.         ;;jecxz .end_f
  1650.         test ecx,ecx
  1651.         jz .end_f
  1652.  
  1653.         mov edi,[ebx+Figure.PoiData]
  1654.         finit
  1655.         fld qword[ebx+Figure.SizeY]
  1656.         fmul qword[ebx+Figure.WScale]
  1657.         fmul qword[ebx+Figure.MScale]
  1658.         fchs
  1659.         fistp dword[CentrY]
  1660.         mov eax,[CentrY]
  1661.         sub eax,[graf_margin_top]
  1662.         sub eax,[graf_margin_bot]
  1663.         add eax,[buf_0.h]
  1664.         sar eax,1
  1665.         add eax,[graf_margin_bot]
  1666.         add eax,[ebx+Figure.MCentrY]
  1667.         mov [CentrY],eax
  1668.         fld qword[ebx+Figure.SizeX]
  1669.         fmul qword[ebx+Figure.WScale]
  1670.         fmul qword[ebx+Figure.MScale]
  1671.         fchs
  1672.         fistp dword[CentrX]
  1673.         mov eax,[CentrX]
  1674.         sub eax,[graf_margin_left]
  1675.         sub eax,[graf_margin_right]
  1676.         add eax,[buf_0.w]
  1677.         sar eax,1
  1678.         add eax,[graf_margin_left]
  1679.         add eax,[ebx+Figure.MCentrX]
  1680.         mov [CentrX],eax
  1681.  
  1682. align 4
  1683.         .cycle0:
  1684.                 fld qword[edi+Point.CoordX]
  1685.                 fsub qword[ebx+Figure.MinX]
  1686.                 fmul qword[ebx+Figure.WScale]
  1687.                 fmul qword[ebx+Figure.MScale]
  1688.                 fiadd dword[CentrX]
  1689.                 fistp dword[GrafX]
  1690.                 fld qword[edi+Point.CoordY]
  1691.                 fsub qword[ebx+Figure.MinY]
  1692.                 fmul qword[ebx+Figure.WScale]
  1693.                 fmul qword[ebx+Figure.MScale]
  1694.                 fiadd dword[CentrY]
  1695.                 fisub dword[buf_0.h] ;invert coord Y
  1696.                 fchs
  1697.                 fistp dword[GrafY]
  1698.  
  1699.                 mov eax,[GrafX]
  1700.                 sub eax,[BufX]
  1701.                 bt eax,31
  1702.                 jnc @f
  1703.                         neg eax
  1704.                 @@:
  1705.                 mov edx,[GrafY]
  1706.                 sub edx,[BufY]
  1707.                 bt edx,31
  1708.                 jnc @f
  1709.                         neg edx
  1710.                 @@:
  1711.                 add eax,edx
  1712.                 cmp eax,7 ;¯à¨¡«¨§¨â¥«ì­®¥ à ááâ®ï­¨¥ ¤® â®çª¨
  1713.                 jg @f
  1714.                         ;¢ë¤¥«ï¥¬ ¨«¨ á­¨¬ ¥¬ ¢ë¤¥«¥­¨¥ á â®ç¥ª
  1715.                         xor dword[edi+Point.Prop],(1 shl PROP_BIT_SELECT)
  1716.                 @@:
  1717.  
  1718.                 add edi,sizeof.Point
  1719.                 dec ecx
  1720.         jnz .cycle0
  1721.  
  1722.                 mov dword[offs_last_timer],0
  1723.                 ;jmp .end_f
  1724.         .end_fblo:
  1725.  
  1726.         .end_f:
  1727.         ret
  1728. endp
  1729.