Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ; ¢ í⮬ ä ©«¥ ᮡ࠭ë ä㭪樨 ­ã¦­ë¥ ¤«ï ᮧ¤ ­¨ï ¨
  3. ; à ¡®âë ®ª­  ᮧ¤ ­¨ï ­®¢®£® ä ©« 
  4. ;
  5.  
  6. wnd_n_file_width  equ 300 ;è¨à¨­  ®ª­  ᮧ¤ ­¨ï ­®¢®£® ä ©« 
  7. wnd_n_file_height equ 200 ;¢ëá®â  ®ª­  ᮧ¤ ­¨ï ­®¢®£® ä ©« 
  8.  
  9. align 4
  10. wnd_n_file db 0 ;¯¥à¥¬¥­­ ï á«¥¤ïé ï §  ⥬ çâ®-¡ë ­¥ § ¯ã᪠âì ¡®«ìè¥ 1-£® ®ª­  ᮧ¤ ­¨ï ­®¢®£® ä ©« 
  11.  
  12. align 4
  13. NOptCoordX0 dq 35.0
  14. NOptCoordY0 dq 25.0
  15. NOptCoordX1 dq 20.0 ;for circle Radius
  16. NOptCoordY1 dq 16.0 ;S
  17. NOptCoordZ0 dq  1.0
  18. NOptCoordZ1 dq  5.0
  19.  
  20. ;¤ ­®¥ ®ª­® (¯à®æ¥áá) ¢ë§ë¢ ¥âìáï ä㭪樥© but_wnd_coords
  21. align 4
  22. start_n_file:
  23. pushad
  24.         mcall SF_SET_EVENTS_MASK,0x27 ;¬ áª  ®¦¨¤ ¥¬ëå ᮡë⨩
  25.         inc byte[wnd_n_file]
  26.  
  27.         edit_boxes_set_sys_color edit4,editboxes_end_nf,sc ;ãáâ ­®¢ª  á¨á⥬­ëå 梥⮢
  28.         option_boxes_set_sys_color sc,opt_grlist1
  29.  
  30.         call get_n_file_opt
  31. popad
  32.         call red_win_n_file
  33.  
  34. ;­¥ ®âà뢠âì íâã äã­ªæ¨î ®â ¯à¥¤ë¤ã饩
  35. align 4
  36. still_n_file:
  37.         pushad
  38.  
  39.         mcall SF_WAIT_EVENT_TIMEOUT,10
  40.         or eax,eax
  41.         jnz @f
  42.                 call timer_funct_n_file
  43.                 jmp .end
  44.         @@:
  45.  
  46.         cmp al,1 ;¨§¬. ¯®«®¦¥­¨¥ ®ª­ 
  47.         jne @f
  48.                 call red_win_n_file
  49.                 jmp .end
  50.         @@:
  51.         cmp al,2
  52.         jne @f
  53.                 call key_n_file
  54.                 jmp .end
  55.         @@:
  56.         cmp al,3
  57.         jz button_n_file
  58.         cmp al,6
  59.         jne @f
  60.                 call mouse_n_file
  61.         @@:
  62. .end:
  63.         popad
  64.         jmp still_n_file
  65.  
  66. align 4
  67. red_win_n_file:
  68. pushad
  69.         mcall SF_REDRAW,SSF_BEGIN_DRAW
  70.  
  71.         mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
  72.         mov edi,capt_n_file ;children window caption
  73.         mov bx,word[procinfo.box.left]
  74.         add bx,word[buf_0.l]
  75.         add bx,5 ;è¨à¨­  ¡®ª®¢®© à ¬ª¨
  76.         shl ebx,16
  77.         mov bx,wnd_n_file_width
  78.         mov cx,word[procinfo.box.top]
  79.         add cx,ax ;add skin height
  80.         add cx,word[buf_0.t]
  81.         shl ecx,16
  82.         mov cx,wnd_n_file_height
  83.         mov edx,[sc.work]
  84.         or  edx,0x33000000
  85.         xor eax,eax
  86.         int 0x40
  87.  
  88.         mov esi,[sc.work_button]
  89.         ;ebx = (l<:)+w, ecx = (t<:)+h
  90.         mcall SF_DEFINE_BUTTON, (5 shl 16)+59, (145 shl 16)+20, 3
  91.         mcall , (75 shl 16)+59, (145 shl 16)+20, 4
  92.  
  93.         mov ecx,[sc.work_text]
  94.         bts ecx,31 ;à¨á㥬 ï áâப  § ª ­ç¨¢ ¥âáï ­ã«ñ¬
  95.         mcall SF_DRAW_TEXT, (5 shl 16)+5,, capt_sel_fig
  96.  
  97.         mcall , (5 shl 16)+32,, capt_coord_x0
  98.         mcall , (5 shl 16)+50,, capt_coord_y0
  99.         cmp [opt_gr1],opt1
  100.         jne @f
  101.                 ;circle
  102.                 mcall , (5 shl 16)+68,, capt_coord_r
  103.                 mcall , (5 shl 16)+86,, capt_coord_s
  104.                 jmp .end0
  105.         @@:
  106.                 ;rect
  107.                 mcall , (5 shl 16)+68,, capt_coord_x1
  108.                 mcall , (5 shl 16)+86,, capt_coord_y1
  109.         .end0:
  110.         mcall , (5 shl 16)+104,,capt_coord_z0
  111.         mcall , (5 shl 16)+122,,capt_coord_z1
  112.  
  113.         mov ecx,[sc.work_button_text]
  114.         bts ecx,31
  115.         mcall , (9 shl 16)+151,, txt_but_cancel
  116.         mcall ,(79 shl 16)+151,, txt_but_create
  117.  
  118.         stdcall [option_box_draw], opt_grlist1
  119.  
  120.         stdcall [edit_box_draw], edit4
  121.         stdcall [edit_box_draw], edit5
  122.         stdcall [edit_box_draw], edit6
  123.         stdcall [edit_box_draw], edit7
  124.         stdcall [edit_box_draw], edit8
  125.         stdcall [edit_box_draw], edit9
  126.  
  127.         mcall SF_REDRAW,SSF_END_DRAW
  128. popad
  129.         ret
  130.  
  131. align 4
  132. proc key_n_file uses eax ebx
  133.         mcall SF_GET_KEY
  134.  
  135.         test word [edit4.flags],10b ;ed_focus
  136.         je @f
  137.                 stdcall [edit_box_key], edit4
  138.                 jmp .end
  139.         @@:
  140.         test word [edit5.flags],10b
  141.         je @f
  142.                 stdcall [edit_box_key], edit5
  143.                 jmp .end
  144.         @@:
  145.         test word [edit6.flags],10b
  146.         je @f
  147.                 stdcall [edit_box_key], edit6
  148.                 jmp .end
  149.         @@:
  150.         test word [edit7.flags],10b
  151.         je @f
  152.                 stdcall [edit_box_key], edit7
  153.                 jmp .end
  154.         @@:
  155.         test word [edit8.flags],10b
  156.         je @f
  157.                 stdcall [edit_box_key], edit8
  158.                 jmp .end
  159.         @@:
  160.         test word [edit9.flags],10b
  161.         je @f
  162.                 stdcall [edit_box_key], edit9
  163.                 ;jmp .end
  164.         @@:
  165.         .end:
  166.         ret
  167. endp
  168.  
  169. align 4
  170. mouse_n_file:
  171.         stdcall [option_box_mouse], opt_grlist1
  172.  
  173.         stdcall [edit_box_mouse], edit4
  174.         stdcall [edit_box_mouse], edit5
  175.         stdcall [edit_box_mouse], edit6
  176.         stdcall [edit_box_mouse], edit7
  177.         stdcall [edit_box_mouse], edit8
  178.         stdcall [edit_box_mouse], edit9
  179.         ret
  180.  
  181. align 4
  182. button_n_file:
  183.         mcall SF_GET_BUTTON
  184.  
  185.         cmp ah,3
  186.         je .exit
  187.         cmp ah,4
  188.         jne .end_save
  189.                 push eax ecx edi esi
  190.                 finit
  191.  
  192.                 mov esi,string4
  193.                 mov edi,Data_String
  194.                 cld
  195.                 mov ecx,8
  196.                 rep movsd
  197.                 call String_to_DoubleFloat
  198.                 fld  qword[Data_Double] ;áç¨â뢠¥¬ ª ª double
  199.                 fstp qword[NOptCoordX0] ;á®å࠭塞 ª ª double
  200.  
  201.                 mov esi,string5
  202.                 mov edi,Data_String
  203.                 cld
  204.                 mov ecx,8
  205.                 rep movsd
  206.                 call String_to_DoubleFloat
  207.                 fld  qword[Data_Double]
  208.                 fstp qword[NOptCoordY0]
  209.  
  210.                 mov esi,string6
  211.                 mov edi,Data_String
  212.                 cld
  213.                 mov ecx,8
  214.                 rep movsd
  215.                 call String_to_DoubleFloat
  216.                 fld  qword[Data_Double]
  217.                 fstp qword[NOptCoordX1]
  218.  
  219.                 mov esi,string7
  220.                 mov edi,Data_String
  221.                 cld
  222.                 mov ecx,8
  223.                 rep movsd
  224.                 call String_to_DoubleFloat
  225.                 fld  qword[Data_Double]
  226.                 fstp qword[NOptCoordY1]
  227.  
  228.                 mov esi,string8
  229.                 mov edi,Data_String
  230.                 cld
  231.                 mov ecx,8
  232.                 rep movsd
  233.                 call String_to_DoubleFloat
  234.                 fld  qword[Data_Double]
  235.                 fstp qword[NOptCoordZ0]
  236.  
  237.                 mov esi,string9
  238.                 mov edi,Data_String
  239.                 cld
  240.                 mov ecx,8
  241.                 rep movsd
  242.                 call String_to_DoubleFloat
  243.                 fld  qword[Data_Double]
  244.                 fstp qword[NOptCoordZ1]
  245.  
  246.                 mov word[NumberSymbolsAD],3
  247.                 ;fld qword[NOptCoordZ1]
  248.                 ;fstp qword[Data_Double]
  249.                 call DoubleFloat_to_String
  250.                 call String_crop_0
  251.                 mov dword[txt_01.z],0
  252.                 mov dword[txt_05.z],0
  253.                 mov dword[txt_06.z],0
  254.                 stdcall str_cat, txt_01.z, Data_String
  255.                 stdcall str_cat, txt_01.z, txt_nl
  256.                 stdcall str_cat, txt_01.z, txt_nl
  257.                 stdcall str_cat, txt_05.z, Data_String
  258.                 stdcall str_cat, txt_05.z, txt_nl
  259.                 stdcall str_cat, txt_05.z, txt_nl
  260.                 stdcall str_cat, txt_06.z, Data_String
  261.                
  262.                 fld qword[NOptCoordZ0]
  263.                 fstp qword[Data_Double]
  264.                 call DoubleFloat_to_String
  265.                 call String_crop_0
  266.                 mov dword[txt_03.z],0
  267.                 stdcall str_cat, txt_03.z, Data_String
  268.  
  269.                 fld qword[NOptCoordX0]
  270.                 cmp [opt_gr1],opt1
  271.                 jne @f
  272.                         ;circle
  273.                         fadd qword[NOptCoordX1]
  274.                 @@:
  275.                 fstp qword[Data_Double]
  276.                 call DoubleFloat_to_String
  277.                 call String_crop_0
  278.                 mov dword[txt_04.x],0
  279.                 stdcall str_cat, txt_04.x, Data_String
  280.                 stdcall str_cat, txt_04.x, txt_s_poi_Y
  281.                 fld qword[NOptCoordY0]
  282.                 fstp qword[Data_Double]
  283.                 call DoubleFloat_to_String
  284.                 call String_crop_0
  285.                 stdcall str_cat, txt_04.x, Data_String
  286.                 mov dword[txt_02.x],0
  287.                 stdcall str_cat, txt_02.x, txt_04.x
  288.                 stdcall str_cat, txt_02.x, txt_s_poi_Z
  289.                 fld qword[NOptCoordZ1]
  290.                 fstp qword[Data_Double]
  291.                 call DoubleFloat_to_String
  292.                 call String_crop_0
  293.                 stdcall str_cat, txt_02.x, Data_String
  294.  
  295.                 ;clear old file
  296.                 stdcall [tl_node_poi_get_info], tree1,0
  297.                 or eax,eax
  298.                 jz @f
  299.                         mov ebx,eax
  300.                         stdcall [tl_node_poi_get_data], tree1,ebx
  301.                         stdcall clear_object_in_list, eax
  302.                 @@:
  303.                 stdcall [tl_info_clear], tree1 ;®ç¨á⪠ ᯨ᪠ ®¡ê¥ªâ®¢
  304.                 mov dword[offs_last_timer],0
  305.  
  306.                 stdcall ObjectCreate,ObjData
  307.                 stdcall [tl_cur_beg], tree1
  308.  
  309.                 mov dword[offs_last_timer],0 ;¤«ï ®¡­®¢«¥­¨ï ¡«®ª  ¢ â ©¬¥à¥
  310.                 pop esi edi ecx eax
  311.                 jmp .exit
  312.         .end_save:
  313.  
  314.         cmp ah,1
  315.         jne still_n_file.end
  316. .exit:
  317.         mov byte[wnd_n_file],0 ;®¡­ã«ï¥¬ áç¥â稪 ®ª®­
  318.         mcall SF_TERMINATE_PROCESS ;¢ë室 ¨§ ¯à®£à ¬¬ë
  319.  
  320. align 4
  321. proc ObjectCreate, pobj:dword
  322. pushad
  323.         mov ebx,[pobj]
  324.         mov [ebx+Object.OType],'Obj'
  325.         mov edi,ebx
  326.         add edi,Object.Caption
  327.         mov dword[edi],'CNC'
  328.  
  329.         mov eax,7 ;max lines
  330.         mov [ebx+Object.FigCount],eax
  331.         mov ecx,eax
  332.  
  333.         shl eax,2
  334.         stdcall mem.Alloc,eax
  335.         mov [ebx+Object.FigData],eax
  336.         push ecx
  337.                 mov edi,eax
  338.                 xor eax,eax
  339.                 rep stosd ;clear memory
  340.         pop ecx
  341.  
  342.         stdcall add_object_in_list,0,0,ebx,0
  343.         ;eax -> pointer to object node
  344.         mov edi,[ebx+Object.FigData]
  345.  
  346.         mov esi,txt_00
  347.         stdcall FigureInit,FigData,edi
  348.         add edi,4
  349.         mov esi,txt_01
  350.         stdcall FigureInit,FigData,edi
  351.         add edi,4
  352.         mov esi,txt_02
  353.         stdcall FigureInit,FigData,edi
  354.         add edi,4
  355.         mov esi,txt_03
  356.         stdcall FigureInit,FigData,edi
  357.         add edi,4
  358.         mov esi,txt_04 ;X__ Y__
  359.         stdcall FigureInit,FigData,edi
  360.         ; *** create new points ***
  361.         mov edx,[edi]
  362.         cmp [opt_gr1],opt1
  363.         jne .rect
  364.                 ;circle
  365.                 fld qword[NOptCoordY1]
  366.                 fistp dword[edx+Figure.PoiCount]
  367.                 inc dword[edx+Figure.PoiCount]
  368.                 mov eax,[edx+Figure.PoiCount]
  369.                 imul eax,sizeof.Point
  370.                 stdcall mem.ReAlloc,[edx+Figure.PoiData],eax
  371.                 mov [edx+Figure.PoiData],eax
  372.  
  373.                 ;init points
  374.                 fldpi
  375.                 fadd st0,st0
  376.                 fdiv qword[NOptCoordY1]
  377.                 fldz
  378.                 ;st0 - angle (=0)
  379.                 ;st1 - delta angle (=pi/slices)
  380.                
  381.                 mov ecx,[edx+Figure.PoiCount]
  382.                 cmp ecx,3
  383.                 jge @f
  384.                         mov ecx,3
  385.                 @@:
  386.                 mov edx,[edx+Figure.PoiData]
  387.                 add edx,Point.CoordX
  388.                 .cycle0:
  389.                         add edx,sizeof.Point
  390.                         fadd st0,st1 ;angle += delta angle
  391.                
  392.                         fld st0
  393.                         fcos
  394.                         fmul qword[NOptCoordX1] ;st0 = cos(angle) * radius
  395.                         fadd qword[NOptCoordX0]
  396.                         fstp qword[edx]
  397.                         fld st0
  398.                         fsin
  399.                         fmul qword[NOptCoordX1] ;st0 = sin(angle) * radius
  400.                         fadd qword[NOptCoordY0]
  401.                         fstp qword[edx+8]
  402.                         loop .cycle0
  403.                 ffree st0
  404.                 fincstp
  405.                 ffree st0
  406.                 fincstp
  407.                 jmp .end0
  408.         .rect:
  409.                 ;rect
  410.                 mov eax,5
  411.                 mov dword[edx+Figure.PoiCount],eax
  412.                 imul eax,sizeof.Point
  413.                 stdcall mem.ReAlloc,[edx+Figure.PoiData],eax
  414.                 mov [edx+Figure.PoiData],eax
  415.                 ;init points
  416.                 push edi
  417.                 mov ecx,[edx+Figure.PoiData]
  418.                 ;p1
  419.                 add ecx,sizeof.Point
  420.                 lea edi,[ecx+Point.CoordX]
  421.                 mov esi,NOptCoordX1
  422.                 movsd
  423.                 movsd
  424.                 mov esi,NOptCoordY0
  425.                 movsd
  426.                 movsd
  427.                 ;p2
  428.                 add ecx,sizeof.Point
  429.                 lea edi,[ecx+Point.CoordX]
  430.                 mov esi,NOptCoordX1
  431.                 movsd
  432.                 movsd
  433.                 mov esi,NOptCoordY1
  434.                 movsd
  435.                 movsd
  436.                 ;p3
  437.                 add ecx,sizeof.Point
  438.                 lea edi,[ecx+Point.CoordX]
  439.                 mov esi,NOptCoordX0
  440.                 movsd
  441.                 movsd
  442.                 mov esi,NOptCoordY1
  443.                 movsd
  444.                 movsd
  445.                 ;p4
  446.                 add ecx,sizeof.Point
  447.                 lea edi,[ecx+Point.CoordX]
  448.                 mov esi,NOptCoordX0
  449.                 movsd
  450.                 movsd
  451.                 mov esi,NOptCoordY0
  452.                 movsd
  453.                 movsd
  454.                 pop edi
  455.         .end0:
  456.         stdcall found_parent_obj,[edi] ;get figure number in ecx
  457.         stdcall figure_update_coords,ObjData,ecx
  458.  
  459.         add edi,4
  460.         mov esi,txt_05
  461.         stdcall FigureInit,FigData,edi
  462.         add edi,4
  463.         mov esi,txt_06
  464.         stdcall FigureInit,FigData,edi
  465.  
  466.         stdcall ObjCalculateScale,ebx
  467. popad
  468.         ret
  469. endp
  470.  
  471. align 4
  472. proc get_n_file_opt uses eax
  473.         ;§ £à㧪  ª®®à¤¨­ â ¢ editbox-ë
  474.         mov word[NumberSymbolsAD],3
  475.         finit
  476.         fld qword[NOptCoordX0]
  477.         fstp qword[Data_Double]
  478.         call DoubleFloat_to_String
  479.         call String_crop_0
  480.         stdcall [edit_box_set_text], edit4, Data_String
  481.         fld qword[NOptCoordY0]
  482.         fstp qword[Data_Double]
  483.         call DoubleFloat_to_String
  484.         call String_crop_0
  485.         stdcall [edit_box_set_text], edit5, Data_String
  486.         fld qword[NOptCoordX1]
  487.         fstp qword[Data_Double]
  488.         call DoubleFloat_to_String
  489.         call String_crop_0
  490.         stdcall [edit_box_set_text], edit6, Data_String
  491.         fld qword[NOptCoordY1]
  492.         fstp qword[Data_Double]
  493.         call DoubleFloat_to_String
  494.         call String_crop_0
  495.         stdcall [edit_box_set_text], edit7, Data_String
  496.         fld qword[NOptCoordZ0]
  497.         fstp qword[Data_Double]
  498.         call DoubleFloat_to_String
  499.         call String_crop_0
  500.         stdcall [edit_box_set_text], edit8, Data_String
  501.         fld qword[NOptCoordZ1]
  502.         fstp qword[Data_Double]
  503.         call DoubleFloat_to_String
  504.         call String_crop_0
  505.         stdcall [edit_box_set_text], edit9, Data_String
  506.         ;
  507.         ;stdcall [edit_box_draw], edit4
  508.         ;stdcall [edit_box_draw], edit5
  509.         ret
  510. endp
  511.  
  512. align 4
  513. proc timer_funct_n_file uses eax
  514.         ;¯à®á¬ âਢ ¥¬ ¢ë¤¥«¥­­ãî ª®®à¤¨­ âã
  515.         mov eax,[opt_gr1]
  516.         cmp eax,[last_opt]
  517.         je @f
  518.                 mov eax,[opt_gr1]
  519.                 mov [last_opt],eax
  520.                 call red_win_n_file
  521.         @@:
  522.         ret
  523. endp
  524.  
  525. capt_coord_x0 db 'X0:',0
  526. capt_coord_y0 db 'Y0:',0
  527. capt_coord_z0 db 'Z0:',0
  528. capt_coord_x1 db 'X1:',0
  529. capt_coord_y1 db 'Y1:',0
  530. capt_coord_z1 db 'Z1:',0
  531. capt_coord_r  db 'R:',0
  532. capt_coord_s  db 'S:',0
  533.  
  534. edit4 edit_box 80, 24, 28, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 34, string4, mouse_dd, 0
  535. edit5 edit_box 80, 24, 46, 0xd0d0ff, 0xff, 0x80ff, 0, 0x8000, 34, string5, mouse_dd, 0
  536. edit6 edit_box 80, 24, 64, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 34, string6, mouse_dd, 0
  537. edit7 edit_box 80, 24, 82, 0xd0d0ff, 0xff, 0x80ff, 0, 0x8000, 34, string7, mouse_dd, 0
  538. edit8 edit_box 80, 24, 100, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 34, string8, mouse_dd, 0
  539. edit9 edit_box 80, 24, 118, 0xd0d0ff, 0xff, 0x80ff, 0, 0x8000, 34, string9, mouse_dd, 0
  540. editboxes_end_nf:
  541.  
  542. string4 rb 34
  543. string5 rb 34
  544. string6 rb 34
  545. string7 rb 34
  546. string8 rb 34
  547. string9 rb 34
  548.  
  549. align 4
  550. last_opt dd opt1 ;for timer
  551. opt_gr1 dd opt1
  552.  
  553. opt1 option_box opt_gr1, 115,28,6,12,0xd0d0ff, 0xff, 0x80ff,txt_circle,txt_circle.end-txt_circle
  554. opt2 option_box opt_gr1, 115,46,6,12,0xd0d0ff, 0xff, 0x80ff,txt_rect,txt_rect.end-txt_rect
  555.  
  556. align 4
  557. opt_grlist1 dd opt1,opt2,0 ;end option group
  558.  
  559. txt_00 db ';PCB graving',0
  560. txt_01: db 'G0 M3 X0 Y0 Z'
  561. .z: rb 12
  562. txt_02: db 'G0 X'
  563. .x: rb 50 ;X__ Y__ Z__
  564. txt_03: db 'G1 F100 Z'
  565. .z: rb 12
  566. txt_04: db 'X'
  567. .x: rb 30 ;X__ Y__
  568. txt_05: db 'G0 Z'
  569. .z: rb 12
  570. txt_06: db 'G0 M5 X0 Y0 Z'
  571. .z: rb 12
  572.  
  573. if lang eq ru
  574. capt_n_file db '‘®§¤ âì ­®¢ë© ä ©«',0
  575. capt_sel_fig db '‚ë¡¥à¨â¥ 䨣ãàã:',0
  576. txt_circle: db 'Žªà㦭®áâì'
  577. .end: db 0
  578. txt_rect: db 'àאַ㣮«ì­¨ª'
  579. .end: db 0
  580. else
  581. capt_n_file db 'Create new file',0
  582. capt_sel_fig db 'Select figure:',0
  583. txt_circle: db 'Circle'
  584. .end: db 0
  585. txt_rect: db 'Rectangle'
  586. .end: db 0
  587. end if