Subversion Repositories Kolibri OS

Rev

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