From 2df98112f7a98a754b2ab3694fcc755c5dc3377e Mon Sep 17 00:00:00 2001 From: theonlymirage Date: Tue, 2 Oct 2018 16:10:39 +0000 Subject: [PATCH] New app "CNC Control": prototype UI git-svn-id: svn://kolibrios.org@7427 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/other/cnc_control/Tupfile.lua | 4 + programs/other/cnc_control/build.bat | 5 + programs/other/cnc_control/cnc_control.asm | 1038 ++++++++++++++++ programs/other/cnc_control/cnc_control.inc | 1254 ++++++++++++++++++++ programs/other/cnc_control/toolbar.png | Bin 0 -> 1303 bytes 5 files changed, 2301 insertions(+) create mode 100644 programs/other/cnc_control/Tupfile.lua create mode 100644 programs/other/cnc_control/build.bat create mode 100644 programs/other/cnc_control/cnc_control.asm create mode 100644 programs/other/cnc_control/cnc_control.inc create mode 100644 programs/other/cnc_control/toolbar.png diff --git a/programs/other/cnc_control/Tupfile.lua b/programs/other/cnc_control/Tupfile.lua new file mode 100644 index 0000000000..e839d0dc1a --- /dev/null +++ b/programs/other/cnc_control/Tupfile.lua @@ -0,0 +1,4 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "ru" or tup.getconfig("LANG")) .. " > lang.inc", {"lang.inc"}) +tup.rule({"cnc_control.asm", extra_inputs = {"lang.inc"}}, "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "cnc_control") + diff --git a/programs/other/cnc_control/build.bat b/programs/other/cnc_control/build.bat new file mode 100644 index 0000000000..11b646755b --- /dev/null +++ b/programs/other/cnc_control/build.bat @@ -0,0 +1,5 @@ +@echo lang fix ru >lang.inc +@fasm.exe -m 16384 cnc_control.asm cnc_control +@erase lang.inc +@kpack cnc_control +@pause \ No newline at end of file diff --git a/programs/other/cnc_control/cnc_control.asm b/programs/other/cnc_control/cnc_control.asm new file mode 100644 index 0000000000..16fb6f9523 --- /dev/null +++ b/programs/other/cnc_control/cnc_control.asm @@ -0,0 +1,1038 @@ +;CNC CONTROL +;Igor Afanasyev (aka IgorA) and Sergey Efremenkov (aka theonlymirage), 2018 + +;02.10.18 - Only prototype UI + +format binary as "" +use32 + org 0 + db 'MENUET01' + dd 1,start,i_end,mem,stacktop,0,sys_path + +include '../../macros.inc' +include '../../proc32.inc' +include '../../KOSfuncs.inc' +include '../../load_img.inc' +include '../../develop/libraries/libs-dev/libimg/libimg.inc' +include '../../develop/libraries/box_lib/trunk/box_lib.mac' +include 'lang.inc' +include 'cnc_control.inc' +include '../../develop/info3ds/info_fun_float.inc' + +@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load +caption db 'CNC Control 02.10.18',0 ;подпись окна + +run_file_70 FileInfoBlock + +offs_last_timer dd 0 ;последний сдвиг показаный в функции таймера + +IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3 +image_data_toolbar dd 0 ;указатель на временную память. для нужен преобразования изображения +icon_tl_sys dd 0 ;указатель на память для хранения системных иконок +icon_toolbar dd 0 ;указатель на память для хранения иконок объектов + +align 4 +start: + load_libraries l_libs_start,l_libs_end + ;проверка на сколько удачно загузилась библиотека + mov ebp,lib_0 + cmp dword [ebp+ll_struc_size-4],0 + jz @f + mcall SF_TERMINATE_PROCESS + @@: + mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors + mcall SF_SET_EVENTS_MASK,0xC0000027 + stdcall [OpenDialog_Init],OpenDialog_data ;подготовка диалога + + stdcall [buf2d_create], buf_0 ;создание буфера + + ;шрифт делаем до создания панели (для экономии указателя image_data_toolbar) + include_image_file '..\..\fs\kfar\trunk\font6x9.bmp', image_data_toolbar, buf_1.w,buf_1.h + stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;создаем буфер + stdcall mem.Free,[image_data_toolbar] ;освобождаем память + stdcall [buf2d_conv_24_to_8], buf_1,1 ;делаем буфер прозрачности 8 бит + stdcall [buf2d_convert_text_matrix], buf_1 + mov eax,[buf_1.h] + shr eax,8 + mov [font_h],eax + + include_image_file 'toolbar.png', image_data_toolbar + + ;*** установка времени для таймера + mcall SF_SYSTEM_GET,SSF_TIME_COUNT + mov [last_time],eax + + ;call but_new_file + option_boxes_set_sys_color sc,opt_grlist1 + + ;mov eax, 68 ;progress bar trash + ;mov ebx, 19 + ;mov ecx, sz_pb_lib + ;int 64 + ;mov [pb_lib], eax + + ;push dword[pb_lib] + ;push sz_progressbar_draw + ;call getprocaddress + ;mov [progressbar_draw], eax + + ;push dword[pb_lib] + ;push sz_progressbar_progress + ;call getprocaddress + ;mov [progressbar_progress], eax + mov [pb.left], dword 50 + mov [pb.top], dword 30 + mov [pb.width], dword 350 + mov [pb.height], dword 17 + mov [pb.max], dword 100;599 + mov [pb.min], dword 0 ;-397 + mov [pb.value], dword 50;-397 + mov [pb.back_color], dword 00C8D0D4h + mov [pb.progress_color], dword 8072B7EBh + mov [pb.frame_color], dword 00406175h + ;mov ecx, [pb.max] + ;sub ecx, [pb.min] + +align 4 +red_win: + call draw_window + +align 4 +still: + mcall SF_SYSTEM_GET,SSF_TIME_COUNT + mov ebx,[last_time] + add ebx,10 ;задержка + cmp ebx,eax + jge @f + mov ebx,eax + @@: + sub ebx,eax + mcall SF_WAIT_EVENT_TIMEOUT + cmp eax,0 + jne @f + call timer_funct + jmp still + @@: + + cmp al,1 + jz red_win + cmp al,2 + jz key + cmp al,3 + jz button + cmp al,6 + jne @f + mcall SF_THREAD_INFO,procinfo,-1 + cmp ax,word[procinfo.window_stack_position] + jne @f ;окно не активно + call mouse + @@: + jmp still + +align 4 +mouse: + stdcall [option_box_mouse], opt_grlist1 + stdcall [edit_box_mouse], editFileName + stdcall [edit_box_mouse], editCommand + + push eax ebx ecx + mcall SF_MOUSE_GET,SSF_BUTTON_EXT + bt eax,8 + jnc @f + ;mouse l. but. press + call mouse_left_d + jmp .end_l + @@: + ;bt eax,0 + ;jnc @f + ;mouse l. but. move + ;call mouse_left_m + ;jmp .end_l + ;@@: + bt eax,16 + jnc .end_l + ;mouse l. but. up + call mouse_left_u + ;jmp .end_l + .end_l: + ;bt eax,9 + ;jnc @f + ;mouse r. but. press + ;jmp .end_r + ;@@: + ;bt eax,1 + ;jnc @f + ;mouse r. but. move + ;call mouse_right_m + ;jmp .end_r + ;@@: + ;.end_r: + + call buf_get_mouse_coord + cmp eax,-1 + je .end0 + shl eax,1 + sub eax,[buf_0.w] + sar eax,1 + mov [mouse_prop_x],eax + mov ecx,ObjData + shl ebx,1 + sub ebx,[buf_0.h] + sar ebx,1 + mov [mouse_prop_y],ebx + + mcall SF_MOUSE_GET,SSF_SCROLL_DATA + test ax,ax + jz .end0 + finit + fld qword[zoom_plus] + fld1 + fsubp + fld st0 ;for Y coord + + ;for X coord + fild dword[mouse_prop_x] + fmulp st1,st0 + + mov ebx,eax + test ax,0x8000 + jnz .decr + ;увеличение масштаба + fchs + fild dword[ecx+Figure.MCentrX] ;add old value + fmul qword[zoom_plus] + faddp + + fld qword[ecx+Figure.MScale] + fmul qword[zoom_plus] + ;if (Figure.MScale>16.0) + ;... + jmp @f + .decr: + ;уменьшение масштаба + fild dword[ecx+Figure.MCentrX] ;add old value + fdiv qword[zoom_plus] + faddp + + fld qword[ecx+Figure.MScale] + fdiv qword[zoom_plus] + fld1 + fcomp + fstsw ax + sahf + jbe @f + ;if (Figure.MScale<1.0) + ffree st0 + fincstp + ffree st0 + fincstp + fldz ;default Figure.MCentrX + fld1 ;default Figure.MScale + mov dword[ecx+Figure.MCentrY],0 + @@: + fstp qword[ecx+Figure.MScale] + fistp dword[ecx+Figure.MCentrX] + + ;for Y coord + fild dword[mouse_prop_y] + fmulp st1,st0 + test bx,0x8000 + jnz .decr_y + ;увеличение масштаба + fild dword[ecx+Figure.MCentrY] ;add old value + fmul qword[zoom_plus] + faddp + jmp @f + .decr_y: + ;уменьшение масштаба + fchs + fild dword[ecx+Figure.MCentrY] ;add old value + fdiv qword[zoom_plus] + faddp + @@: + fistp dword[ecx+Figure.MCentrY] + + mov dword[offs_last_timer],0 + .end0: + + pop ecx ebx eax + ret + +;output: +; eax - buffer coord X (если курсор за буфером -1) +; ebx - buffer coord Y (если курсор за буфером -1) +align 4 +proc buf_get_mouse_coord + mcall SF_MOUSE_GET,SSF_WINDOW_POSITION + cmp ax,word[buf_0.t] + jl .no_buf ;не попали в окно буфера по оси y + mov ebx,eax + shr ebx,16 + cmp bx,word[buf_0.l] + jl .no_buf ;не попали в окно буфера по оси x + + and eax,0xffff ;оставляем координату y + sub ax,word[buf_0.t] + cmp eax,[buf_0.h] + jg .no_buf + sub bx,word[buf_0.l] + cmp ebx,[buf_0.w] + jg .no_buf + xchg eax,ebx + jmp .end_f + .no_buf: + xor eax,eax + not eax + xor ebx,ebx + not ebx + .end_f: + ret +endp + +align 4 +proc timer_funct + pushad + mcall SF_SYSTEM_GET,SSF_TIME_COUNT + mov [last_time],eax + + cmp dword[offs_last_timer],ObjData + je @f + mov dword[offs_last_timer],ObjData + stdcall draw_obj2d,ObjData + stdcall [buf2d_draw], buf_0 + @@: + popad + ret +endp + +align 4 +draw_window: +pushad + mcall SF_REDRAW,SSF_BEGIN_DRAW + + ; *** рисование главного окна (выполняется 1 раз при запуске) *** + mov edx,[sc.work] + or edx,0x33000000 + mov edi,caption + mcall SF_CREATE_WINDOW,(20 shl 16)+775,(20 shl 16)+445 + + ;;mcall SF_THREAD_INFO,procinfo,-1 + ;;mov eax,dword[procinfo.box.height] + ;;cmp eax,120 + ;;jge @f + ;;mov eax,120 ;min size + ;;@@: + ;;sub eax,65 + ;;mov ebx,dword[procinfo.box.width] + ;;cmp ebx,270 + ;;jge @f + ;;mov ebx,270 + ;;@@: + ;;sub ebx,215 + ;;cmp eax,dword[buf_0.h] ;смотрим размер буфера + ;;jne @f + ;;cmp ebx,dword[buf_0.w] + ;;jne @f + ;;jmp .end0 + ;;@@: + ;;stdcall [buf2d_resize],buf_0,ebx,eax,1 + mov ecx,[ObjData.FigCount] + or ecx,ecx + jz .end0 + mov eax,[ObjData.FigData] + xor edx,edx + .cycle0: + stdcall FigCalculateSizes,[eax+4*edx],0 + inc edx + loop .cycle0 + stdcall ObjCalculateScale,ObjData + mov dword[offs_last_timer],0 + call timer_funct + .end0: + + stdcall [edit_box_draw], editFileName + stdcall [edit_box_draw], editCommand + + stdcall [option_box_draw], opt_grlist1 + push pb + call [progressbar_draw] + + ; *** создание кнопок на панель *** + mcall SF_DEFINE_BUTTON,(731 shl 16)+20,(75 shl 16)+20,3, [sc.work_button] + mcall , (15 shl 16)+20,(27 shl 16)+20,4 ;restore + mcall ,(538 shl 16)+20,,5 ;connect + mcall ,(563 shl 16)+20,,6 ;close connect + mcall ,(437 shl 16)+86,(378 shl 16)+20,7 ;cancel + mcall ,(616 shl 16)+136,(378 shl 16)+20,8 ;run + + ; *** + mov ecx,[sc.work_text] + or ecx,0x81000000 + mcall SF_DRAW_TEXT,(15 shl 16)+5,,txt_preview + mcall ,(424 shl 16)+5,,txt_port + mov ecx,[sc.work_button_text] + or ecx,0x81000000 + mcall ,(440 shl 16)+381,,txt_but_cancel + mcall ,(619 shl 16)+381,,txt_but_run + + ; *** рисование иконок на кнопках *** + mcall SF_PUT_IMAGE,[image_data_toolbar],(16 shl 16)+16,(733 shl 16)+77 ;icon open + + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(17 shl 16)+29 ;restore scale + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(540 shl 16)+29 ;connect + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(565 shl 16)+29 ;close connect + ;;add ebx,IMAGE_TOOLBAR_ICON_SIZE + ;;mcall ,,,(439 shl 16)+380 ;cancel + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,((638+97) shl 16)+380 ;run + + stdcall [buf2d_draw], buf_0 + + mcall SF_REDRAW,SSF_END_DRAW +popad + ret + +align 4 +key: + mcall SF_GET_KEY + + stdcall [edit_box_key], editFileName + stdcall [edit_box_key], editCommand + + mov ecx,eax + mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS + bt eax,2 ;left Ctrl + jc .key_Ctrl + bt eax,3 ;right Ctrl + jc .key_Ctrl + jmp .end0 + .key_Ctrl: + cmp ch,15 ;111 ;Ctrl+O + jne @f + call but_open_file + @@: + .end0: + jmp still + +align 4 +button: + mcall SF_GET_BUTTON + cmp ah,3 + jne @f + call but_open_file + jmp still + @@: + cmp ah,4 + jne @f + call but_restore_zoom + jmp still + @@: + + ;cmp ah,5 + ;jne @f + ;call but_... + ;jmp still + ;@@: + cmp ah,1 + jne still +.exit: + stdcall [buf2d_delete],buf_0 + stdcall mem.Free,[image_data_toolbar] + stdcall mem.Free,[open_file_data] + mcall SF_TERMINATE_PROCESS + + + +align 4 +open_file_data dd 0 ;указатель на память для открытия файлов +open_file_size dd 0 ;размер открытого файла + +align 4 +but_open_file: + pushad + copy_path open_dialog_name,communication_area_default_path,file_name,0 + mov [OpenDialog_data.type],0 + stdcall [OpenDialog_Start],OpenDialog_data + cmp [OpenDialog_data.status],2 + je .end_open_file + ;код при удачном открытии диалога + + push eax ebx ecx edx ;copy file name path + mov eax, openfile_path ;dword[OpenDialog_data.openfile_path] + mov ebx, fileNameBuffer ;.data + mov ecx, 0 + @@: + mov dl, byte[eax] + cmp dl, 0 ;byte[eax], 0 + je @f + mov byte[ebx], dl + inc eax + inc ebx + inc ecx + jmp @b + @@: + mov byte[ebx], 0 + mov dword[fileNameBuffer.size], ecx + mov dword[editFileName.size], ecx + mov dword[editFileName.pos], ecx + pop edx ecx ebx eax + + mov [run_file_70.Function], SSF_GET_INFO + mov [run_file_70.Position], 0 + mov [run_file_70.Flags], 0 + mov dword[run_file_70.Count], 0 + mov dword[run_file_70.Buffer], open_b + mov byte[run_file_70+20], 0 + mov dword[run_file_70.FileName], openfile_path + mcall SF_FILE,run_file_70 + + mov ecx,dword[open_b+32] ;+32 qword: размер файла в байтах + inc ecx ;for text files + stdcall mem.ReAlloc,[open_file_data],ecx + mov [open_file_data],eax + dec ecx ;for text files + mov byte[eax+ecx],0 ;for text files + + mov [run_file_70.Function], SSF_READ_FILE + mov [run_file_70.Position], 0 + mov [run_file_70.Flags], 0 + mov dword[run_file_70.Count], ecx + m2m dword[run_file_70.Buffer], dword[open_file_data] + mov byte[run_file_70+20], 0 + mov dword[run_file_70.FileName], openfile_path + mcall SF_FILE,run_file_70 ;загружаем файл изображения + test eax,eax + jnz .end_open_file + cmp ebx,0xffffffff + je .end_open_file + + mov [open_file_size],ebx + mcall SF_SET_CAPTION,1,openfile_path + + ;--- + stdcall FileInit,[open_file_data],[open_file_size] + stdcall [buf2d_clear], buf_0, [buf_0.color] ;чистим буфер + stdcall [buf2d_draw], buf_0 ;обновляем буфер на экране + .end_open_file: + popad + ret + +;output: +; ecx - memory size for save file +align 4 +proc get_file_save_size uses eax ebx edx esi + mov ecx,100 ;title + mov ebx,ObjData + add ecx,50 ;object + mov edx,[ebx+Object.FigCount] + or edx,edx + jz .cycle1end + mov esi,[ebx+Object.FigData] +align 4 + .cycle1: ; цикл по фигурам + add ecx,80 ;figure + mov eax,[esi] + or eax,eax + jz @f + mov eax,[eax+Figure.PoiCount] + imul eax,70 + add ecx,eax ;points + @@: + add esi,4 + dec edx + jnz .cycle1 + .cycle1end: + ret +endp + +align 4 +proc but_restore_zoom + finit + fld1 + fstp qword[ObjData.MScale] + mov dword[ObjData.MCentrX],0 + mov dword[ObjData.MCentrY],0 + mov dword[offs_last_timer],0 + ret +endp + + + +;input: +; buf - указатель на строку, число должно быть в 10 или 16 ричном виде +;output: +; eax - число +align 4 +proc conv_str_to_int uses ebx ecx esi, buf:dword + xor eax,eax + xor ebx,ebx + mov esi,[buf] + + ;на случай если перед числом находятся пробелы + @@: + cmp byte[esi],' ' + jne @f + inc esi + jmp @b + @@: + + ;определение отрицательных чисел + xor ecx,ecx + inc ecx + cmp byte[esi],'-' + jne @f + dec ecx + inc esi + @@: + + cmp word[esi],'0x' + je .load_digit_16 + + .load_digit_10: ;считывание 10-тичных цифр + mov bl,byte[esi] + cmp bl,'0' + jl @f + cmp bl,'9' + jg @f + sub bl,'0' + imul eax,10 + add eax,ebx + inc esi + jmp .load_digit_10 + jmp @f + + .load_digit_16: ;считывание 16-ричных цифр + add esi,2 + .cycle_16: + mov bl,byte[esi] + cmp bl,'0' + jl @f + cmp bl,'f' + jg @f + cmp bl,'9' + jle .us1 + cmp bl,'A' + jl @f ;отсеиваем символы >'9' и <'A' + .us1: ;составное условие + cmp bl,'F' + jle .us2 + cmp bl,'a' + jl @f ;отсеиваем символы >'F' и <'a' + sub bl,32 ;переводим символы в верхний регистр, для упрощения их последущей обработки + .us2: ;составное условие + sub bl,'0' + cmp bl,9 + jle .cor1 + sub bl,7 ;convert 'A' to '10' + .cor1: + shl eax,4 + add eax,ebx + inc esi + jmp .cycle_16 + @@: + cmp ecx,0 ;если число отрицательное + jne @f + sub ecx,eax + mov eax,ecx + @@: + ret +endp + + +;данные для диалога открытия файлов +align 4 +OpenDialog_data: +.type dd 0 ;0 - открыть, 1 - сохранить, 2 - выбрать дтректорию +.procinfo dd procinfo ;+4 +.com_area_name dd communication_area_name ;+8 +.com_area dd 0 ;+12 +.opendir_path dd plugin_path ;+16 +.dir_default_path dd default_dir ;+20 +.start_path dd file_name ;+24 путь к диалогу открытия файлов +.draw_window dd draw_window ;+28 +.status dd 0 ;+32 +.openfile_path dd openfile_path ;+36 путь к открываемому файлу +.filename_area dd filename_area ;+40 +.filter_area dd Filter +.x: +.x_size dw 420 ;+48 ; Window X size +.x_start dw 10 ;+50 ; Window X position +.y: +.y_size dw 320 ;+52 ; Window y size +.y_start dw 10 ;+54 ; Window Y position + +default_dir db '/rd/1',0 + +communication_area_name: + db 'FFFFFFFF_open_dialog',0 +open_dialog_name: + db 'opendial',0 +communication_area_default_path: + db '/rd/1/File managers/',0 + +Filter: +dd Filter.end - Filter ;.1 +.1: +db 'NC',0 +db 'PNG',0 +.end: +db 0 + + + +head_f_i: +head_f_l db 'Системная ошибка',0 + +system_dir_0 db '/sys/lib/' +lib_name_0 db 'proc_lib.obj',0 +err_message_found_lib_0 db 'Не найдена библиотека ',39,'proc_lib.obj',39,0 +err_message_import_0 db 'Ошибка при импорте библиотеки ',39,'proc_lib.obj',39,0 + +system_dir_1 db '/sys/lib/' +lib_name_1 db 'libimg.obj',0 +err_message_found_lib_1 db 'Не найдена библиотека ',39,'libimg.obj',39,0 +err_message_import_1 db 'Ошибка при импорте библиотеки ',39,'libimg.obj',39,0 + +system_dir_2 db '/sys/lib/' +lib_name_2 db 'buf2d.obj',0 +err_msg_found_lib_2 db 'Не найдена библиотека ',39,'buf2d.obj',39,0 +err_msg_import_2 db 'Ошибка при импорте библиотеки ',39,'buf2d',39,0 + +system_dir_3 db '/sys/lib/' +lib_name_3 db 'box_lib.obj',0 +err_msg_found_lib_3 db 'Не найдена библиотека ',39,'box_lib.obj',39,0 +err_msg_import_3 db 'Ошибка при импорте библиотеки ',39,'box_lib',39,0 + +l_libs_start: + lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\ + err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i + lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\ + err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i + lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\ + err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i + lib_3 l_libs lib_name_3, sys_path, file_name, system_dir_3,\ + err_msg_found_lib_3, head_f_l, import_box_lib,err_msg_import_3,head_f_i +l_libs_end: + +align 4 +import_libimg: + dd alib_init1 + img_is_img dd aimg_is_img + img_info dd aimg_info + img_from_file dd aimg_from_file + img_to_file dd aimg_to_file + img_from_rgb dd aimg_from_rgb + img_to_rgb dd aimg_to_rgb + img_to_rgb2 dd aimg_to_rgb2 + img_decode dd aimg_decode + img_encode dd aimg_encode + img_create dd aimg_create + img_destroy dd aimg_destroy + img_destroy_layer dd aimg_destroy_layer + img_count dd aimg_count + img_lock_bits dd aimg_lock_bits + img_unlock_bits dd aimg_unlock_bits + img_flip dd aimg_flip + img_flip_layer dd aimg_flip_layer + img_rotate dd aimg_rotate + img_rotate_layer dd aimg_rotate_layer + img_draw dd aimg_draw + + dd 0,0 + alib_init1 db 'lib_init',0 + aimg_is_img db 'img_is_img',0 ;определяет по данным, может ли библиотека сделать из них изображение + aimg_info db 'img_info',0 + aimg_from_file db 'img_from_file',0 + aimg_to_file db 'img_to_file',0 + aimg_from_rgb db 'img_from_rgb',0 + aimg_to_rgb db 'img_to_rgb',0 ;преобразование изображения в данные RGB + aimg_to_rgb2 db 'img_to_rgb2',0 + aimg_decode db 'img_decode',0 ;автоматически определяет формат графических данных + aimg_encode db 'img_encode',0 + aimg_create db 'img_create',0 + aimg_destroy db 'img_destroy',0 + aimg_destroy_layer db 'img_destroy_layer',0 + aimg_count db 'img_count',0 + aimg_lock_bits db 'img_lock_bits',0 + aimg_unlock_bits db 'img_unlock_bits',0 + aimg_flip db 'img_flip',0 + aimg_flip_layer db 'img_flip_layer',0 + aimg_rotate db 'img_rotate',0 + aimg_rotate_layer db 'img_rotate_layer',0 + aimg_draw db 'img_draw',0 + +align 4 +proclib_import: ;описание экспортируемых функций + OpenDialog_Init dd aOpenDialog_Init + OpenDialog_Start dd aOpenDialog_Start +dd 0,0 + aOpenDialog_Init db 'OpenDialog_init',0 + aOpenDialog_Start db 'OpenDialog_start',0 + +align 4 +import_buf2d: + init dd sz_init + buf2d_create dd sz_buf2d_create + buf2d_create_f_img dd sz_buf2d_create_f_img + buf2d_clear dd sz_buf2d_clear + buf2d_draw dd sz_buf2d_draw + buf2d_delete dd sz_buf2d_delete + buf2d_resize dd sz_buf2d_resize + buf2d_line dd sz_buf2d_line + buf2d_line_sm dd sz_buf2d_line_sm + buf2d_rect_by_size dd sz_buf2d_rect_by_size + buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size + buf2d_circle dd sz_buf2d_circle + buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2 + buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2 + buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8 + buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32 + buf2d_bit_blt dd sz_buf2d_bit_blt + buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp + buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha + buf2d_curve_bezier dd sz_buf2d_curve_bezier + buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix + buf2d_draw_text dd sz_buf2d_draw_text + buf2d_crop_color dd sz_buf2d_crop_color + buf2d_flip_h dd sz_buf2d_flip_h + buf2d_flip_v dd sz_buf2d_flip_v + buf2d_offset_h dd sz_buf2d_offset_h + buf2d_flood_fill dd sz_buf2d_flood_fill + buf2d_set_pixel dd sz_buf2d_set_pixel + dd 0,0 + sz_init db 'lib_init',0 + sz_buf2d_create db 'buf2d_create',0 + sz_buf2d_create_f_img db 'buf2d_create_f_img',0 + sz_buf2d_clear db 'buf2d_clear',0 + sz_buf2d_draw db 'buf2d_draw',0 + sz_buf2d_delete db 'buf2d_delete',0 + sz_buf2d_resize db 'buf2d_resize',0 + sz_buf2d_line db 'buf2d_line',0 + sz_buf2d_line_sm db 'buf2d_line_sm',0 + sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 + sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 + sz_buf2d_circle db 'buf2d_circle',0 + sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 + sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 + sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0 + sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0 + sz_buf2d_bit_blt db 'buf2d_bit_blt',0 + sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0 + sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0 + sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0 + sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0 + sz_buf2d_draw_text db 'buf2d_draw_text',0 + sz_buf2d_crop_color db 'buf2d_crop_color',0 + sz_buf2d_flip_h db 'buf2d_flip_h',0 + sz_buf2d_flip_v db 'buf2d_flip_v',0 + sz_buf2d_offset_h db 'buf2d_offset_h',0 + sz_buf2d_flood_fill db 'buf2d_flood_fill',0 + sz_buf2d_set_pixel db 'buf2d_set_pixel',0 + +align 4 +import_box_lib: + dd sz_init1 + + init_checkbox dd sz_Init_checkbox + check_box_draw dd sz_Check_box_draw + check_box_mouse dd sz_Check_box_mouse + ;version_ch dd sz_Version_ch + + option_box_draw dd sz_Option_box_draw + option_box_mouse dd sz_Option_box_mouse + ;version_op dd sz_Version_op + + edit_box_draw dd sz_edit_box_draw + edit_box_key dd sz_edit_box_key + edit_box_mouse dd sz_edit_box_mouse + edit_box_set_text dd sz_edit_box_set_text + scrollbar_ver_draw dd sz_scrollbar_ver_draw + scrollbar_hor_draw dd sz_scrollbar_hor_draw + + progressbar_draw dd sz_progressbar_draw + progressbar_progress dd sz_progressbar_progress + + dd 0,0 + sz_init1 db 'lib_init',0 + + sz_Init_checkbox db 'init_checkbox2',0 + sz_Check_box_draw db 'check_box_draw2',0 + sz_Check_box_mouse db 'check_box_mouse2',0 + ;sz_Version_ch db 'version_ch2',0 + + sz_Option_box_draw db 'option_box_draw',0 + sz_Option_box_mouse db 'option_box_mouse',0 + ;sz_Version_op db 'version_op',0 + + sz_edit_box_draw db 'edit_box',0 + sz_edit_box_key db 'edit_box_key',0 + sz_edit_box_mouse db 'edit_box_mouse',0 + sz_edit_box_set_text db 'edit_box_set_text',0 + sz_scrollbar_ver_draw db 'scrollbar_v_draw',0 + sz_scrollbar_hor_draw db 'scrollbar_h_draw',0 + + sz_progressbar_draw db 'progressbar_draw', 0 + sz_progressbar_progress db 'progressbar_progress', 0 + +align 4 +mouse_dd dd 0 +last_time dd 0 + +align 16 +sc system_colors + +align 16 +procinfo process_information + +align 4 +buf_0: dd 0 ;указатель на буфер изображения +.l: dw 15 ;+4 left +.t: dw 50 ;+6 top +.w: dd 384 ;+8 w +.h: dd 350 ;+12 h +.color: dd 0xffffd0 ;+16 color + db 24 ;+20 bit in pixel + +align 4 +buf_1: + dd 0 ;указатель на буфер изображения + dd 0 ;+4 left,top +.w: dd 0 +.h: dd 0,0,24 ;+12 color,bit in pixel + +font_h dd 0 ;высота шрифта + +;input: +; eax - число +; edi - буфер для строки +; len - длинна буфера +;output: +align 4 +proc convert_int_to_str uses eax ecx edx edi esi, len:dword + mov esi,[len] + add esi,edi + dec esi + call .str + ret +endp + +align 4 +.str: + mov ecx,10 + cmp eax,ecx + jb @f + xor edx,edx + div ecx + push edx + ;dec edi ;смещение необходимое для записи с конца строки + call .str + pop eax + @@: + cmp edi,esi + jge @f + or al,0x30 + stosb + mov byte[edi],0 ;в конец строки ставим 0, что-бы не вылазил мусор + @@: + ret + +align 4 +proc mem_copy uses ecx esi edi, destination:dword, source:dword, len:dword + cld + mov esi, dword[source] + mov edi, dword[destination] + mov ecx, dword[len] + rep movsb + ret +endp + +edMaxSize = 511 +edMax = 0 ;max, size, pos + +align 4 +editFileName edit_box 270,450,78, 0xffffff, 0x6a9480, 0, 0xAABBCC, 0, edMaxSize, fileNameBuffer.data, mouse_dd, 0, edMax, edMax +editCommand edit_box 150,450,121, 0xffffff, 0x6a9480, 0, 0xAABBCC, 0, edMaxSize, commandBuffer.data, mouse_dd, 0, edMax, edMax + +opt1 option_box opt_gr1, 433,64, 6,12,0xd0d0ff, 0xff, 0x80ff,txt_filename,txt_filename.end-txt_filename +opt2 option_box opt_gr1, 433,107,6,12,0xd0d0ff, 0xff, 0x80ff,txt_command,txt_command.end-txt_command +opt_gr1 dd opt1 +align 4 +opt_grlist1 dd opt1,opt2,0 ;end option group + +;progressbar_progress dd 0 +;progressbar_draw dd 0 +;pb_lib dd 0 +;sz_pb_lib db "/sys/lib/box_lib.obj",0 +pb: +.value dd 0 +.left dd 0 +.top dd 0 +.width dd 0 +.height dd 0 +.style dd 0 +.min dd 0 +.max dd 0 +.back_color dd 0 +.progress_color dd 0 +.frame_color dd 0 + +test_path db '/rd/1/test.txt', 0 +;getprocaddress: +; mov edx, [esp + 8] ; hlib +; xor eax, eax +; test edx, edx ; If hlib = 0 then goto .end +; jz .end +;.next: +; cmp [edx], dword 0 ; If end of export table then goto .end +; jz .end + +; xor eax, eax +; mov esi, [edx] +; mov edi, [esp + 4] ; name +;.next_: +; lodsb +; scasb +; jne .fail +; or al, al +; jnz .next_ +; jmp .ok +;.fail: +; add edx, 8 +; jmp .next +;.ok: ; return address +; mov eax, [edx + 4] +;.end: +; ret 8 + +fileNameBuffer: +.data: rb 512 +.size: rd 1 +fileNameBufferEnd: + +commandBuffer: +.data: rb 512 +.size: rd 1 +commandBufferEnd: + +align 16 +i_end: + rb 2048 +thread_coords: + rb 2048 +thread_scale: + rb 2048 +thread_n_file: + rb 2048 +stacktop: + sys_path rb 1024 + file_name: + rb 1024 ;4096 + library_path rb 1024 + plugin_path rb 4096 + openfile_path rb 4096 + filename_area rb 256 +mem: + diff --git a/programs/other/cnc_control/cnc_control.inc b/programs/other/cnc_control/cnc_control.inc new file mode 100644 index 0000000000..33a67cf803 --- /dev/null +++ b/programs/other/cnc_control/cnc_control.inc @@ -0,0 +1,1254 @@ + +;FigureInit, (Object.FigData) + +;add_object_in_list, (врем. стр.), (Object.FigData) +; mov [Object.FigData], (tl_node_add(врем. стр.),tl_node_get_data) + +;draw_fig2d_litl, ___, pobj, (Object.FigData), ___, ___, ___ + +struct Object + OType dd ? + FigCount dd ? + FigData dd ? ;array pointers to Figures + MinX dq ? + MinY dq ? + SizeX dq ? + SizeY dq ? + WScale dq ? ;prewiew window scale + MScale dq ? ;mouse scale (show partition figure) + MCentrX dd ? ;mouse centr X + MCentrY dd ? ;mouse centr Y + Caption rb 32 +ends + +struct Figure + OType dd ? + PoiCount dd ? + PoiData dd ? + MinX dq ? + MinY dq ? + SizeX dq ? + SizeY dq ? + WScale dq ? ;prewiew window scale (show all figure) + MScale dq ? ;mouse scale (show partition figure) + MCentrX dd ? ;mouse centr X + MCentrY dd ? ;mouse centr Y + Caption rb 32 +ends + +struct Point + Prop dd ? ;prorerties + CoordX dq ? ;coord X + CoordY dq ? ;coord Y +ends + +txt_err_1 db 'Ошибка при считывании объекта',0 +txt_err_2 db 'Ошибка при считывании фигуры',0 +txt_err_3 db 'Не найдена точка в фигуре',0 +txt_err_no_figure_select db 'Не выбрана команда для перемещения',0 +txt_err_figure_is_0 db 'Команда не может быть сдвинута вверх,',13,10,'она в начале списка.',0 +txt_err_figure_is_last db 'Команда не может быть сдвинута вниз,',13,10,'она в конце списка.',0 +txt_err_no_point_del db 'Не можна удалить все точки из фигуры.',0 +txt_err_poi_is_0 db 'Не можна переместить точку вверх,',13,10,'она в начале списка.',0 +txt_err_poi_is_last db 'Не можна переместить точку вниз,',13,10,'она в конце списка.',0 +txt_err_no_1_point_sel db 'Выберите не больше одной точки.',0 + +txt_min_x db 'min x: ',0 +txt_min_y db 'min y: ',0 + +if lang eq ru +; +; rus +; +txt_preview db 'Предпросмотр результата:',0 +txt_port db 'Порт:',0 +txt_but_cancel db 'Отмена',0 +txt_but_run db 'Выполнить',0 +txt_size_x db 'размер x: ',0 +txt_size_y db 'размер y: ',0 +txt_command: + db 'Команда:', 0 + .end: +txt_filename: + db 'Файл (полный путь):', 0 + .end: +else +; +; eng +; +txt_preview db 'Preview:',0 +txt_port db 'Port:',0 +txt_but_cancel db 'Cancel',0 +txt_but_run db 'Run',0 +txt_size_x db 'size x: ',0 +txt_size_y db 'size y: ',0 +txt_command: + db 'Command:', 0 + .end: +txt_filename: + db 'Full file name (path):', 0 + .end: +end if + +align 4 +txt_s_poi db 'X',0 +txt_s_poi_Y db ' Y',0 +txt_s_poi_Z db ' Z',0 +txt_n db 13,0 + +align 4 +zoom_plus dq 1.25992105 +mouse_prop_x dd 0 ;курсор мыши относительно центра окна buf_0 (для измен. масштаба) +mouse_prop_y dd 0 +mouse_down_x dd 0 ;курсор мыши относительно левого верхнего угла окна buf_0 (для сдвига фигуры) +mouse_down_y dd 0 +opt_draw dd 1 +graf_margin_left dd 3 ;margin in pixels +graf_margin_right dd 3+6 ;margin in pixels +graf_margin_top dd 3+9 ;margin in pixels +graf_margin_bot dd 3+9 ;margin in pixels +png_data dd ? +png_size dd ? + +;global variables: +ObjData Object +FigData Figure ;временная структура для заполнения tree1 +PoiData Point + +size_one_list equ sizeof.Figure ;max (sizeof.Figure, sizeof.Object) + +if sizeof.Object > sizeof.Figure + ... need fix size_one_list +end if + +if (Object.FigCount <> Figure.PoiCount) | (Object.FigData <> Figure.PoiData) | (Object.MScale <> Figure.MScale) | (Object.MCentrX <> Figure.MCentrX) | (Object.MCentrY <> Figure.MCentrY) + ... need fix offsets +end if + +txt_buf rb 80 ;??? +txt_sp db ' ',0 + +;input: +; esi - text pointer +align 4 +proc txt_next_line uses eax ecx edi, mlen:dword + mov al,13 + mov ecx,[mlen] + mov edi,esi + repne scasb + cmp byte[edi],10 + jne @f + inc edi + @@: + mov esi,edi + ret +endp + +;input: +; edi - destination buffer +; esi - source text string: '...\nl +; mlen - maximum len destination buffer +align 4 +proc txt_load_line uses eax ebx ecx esi, mlen:dword + mov byte[edi],0 + mov al,13 + cmp byte[esi],al + je .end_f + mov ecx,[mlen] + mov ebx,edi + mov edi,esi + repne scasb ;found end of string + mov ecx,edi + sub ecx,esi + dec ecx ;ecx = string len + mov edi,ebx + rep movsb ;copy caption string + cmp byte[esi],13 + je @f + .cycle0: + inc esi + cmp byte[esi],13 + jne .cycle0 + @@: + mov byte[edi],0 + inc esi + .end_f: + ret +endp + +;input: +; itxt - input description text +; msize - max size +align 4 +proc FileInit uses eax ebx ecx edi esi, itxt:dword, msize:dword + cmp dword[ObjData.FigData],0 + je @f + cmp dword[ObjData.FigCount],0 ;or Figure.PoiCount + je @f + stdcall mem.Free,[ObjData.FigData] ;or Figure.PoiData + @@: + mov dword[offs_last_timer],0 + + mov esi,[itxt] + mov ebx,esi + add ebx,[msize] + stdcall ObjectInit,ObjData,ebx + ret +endp + +;input: +; esi - input description text +; pobj - pointer to object struct +; etxt - pointer to end of input text +align 4 +proc ObjectInit uses eax ebx ecx edi, pobj:dword, etxt:dword + mov ebx,[pobj] + mov [ebx+Object.OType],'Obj' + mov edi,ebx + add edi,Object.Caption + mov dword[edi],'CNC' + + stdcall get_max_lines + test eax,eax + jz .err_init + mov [ebx+Object.FigCount],eax + mov ecx,eax + + shl eax,2 + stdcall mem.Alloc,eax + mov [ebx+Object.FigData],eax + push ecx + mov edi,eax + xor eax,eax + rep stosd ;clear memory + pop ecx + + mov edi,[ebx+Object.FigData] +align 4 + .cycle0: + stdcall FigureInit,edi + cmp esi,[etxt] + jge .cycle0end + add edi,4 + loop .cycle0 + .cycle0end: + inc dword[ebx+Object.FigCount] ;??? + or ecx,ecx + jz @f + ;уменьшаем объем памяти выделенный для команд + sub [ebx+Object.FigCount],ecx + mov eax,[ebx+Object.FigCount] + shl eax,2 + stdcall mem.ReAlloc,[ebx+Object.FigData],eax + mov [ebx+Object.FigData],eax + @@: + + stdcall ObjCalculateScale,ebx + + jmp .end_f + .err_init: + notify_window_run txt_err_1 + .end_f: + ret +endp + +align 4 +proc ObjCalculateScale uses eax ebx ecx edi, pobj:dword + mov ebx,[pobj] + + ;*** Calculate scale for object *** + finit + + ;found min coord X + mov ecx,[ebx+Object.FigCount] + jecxz .cycle2end + mov edi,[ebx+Object.FigData] + @@: + mov eax,[edi] + dec ecx + jecxz .cycle2end + add edi,4 + or eax,eax + jz @b + cmp [eax+Figure.PoiCount],0 + je @b + push edi esi ;copy first min X + lea esi,[eax+Figure.MinX] + lea edi,[ebx+Object.MinX] + movsd + movsd + pop esi edi +align 4 + .cycle2: + mov eax,[edi] + or eax,eax + jz @f + cmp [eax+Figure.PoiCount],0 + je @f + fld qword[eax+Figure.MinX] + fcomp qword[ebx+Object.MinX] + fstsw ax + sahf + jae @f + push edi esi + mov eax,[edi] + lea esi,[eax+Figure.MinX] + lea edi,[ebx+Object.MinX] + movsd + movsd + pop esi edi + @@: + add edi,4 + loop .cycle2 + .cycle2end: + + ;found min coord Y + mov ecx,[ebx+Object.FigCount] + jecxz .cycle3end + mov edi,[ebx+Object.FigData] + @@: + mov eax,[edi] + dec ecx + jecxz .cycle3end + add edi,4 + or eax,eax + jz @b + cmp [eax+Figure.PoiCount],0 + je @b + push edi esi ;copy first min Y + lea esi,[eax+Figure.MinY] + lea edi,[ebx+Object.MinY] + movsd + movsd + pop esi edi +align 4 + .cycle3: + mov eax,[edi] + or eax,eax + jz @f + cmp [eax+Figure.PoiCount],0 + je @f + fld qword[eax+Figure.MinY] + fcomp qword[ebx+Object.MinY] + fstsw ax + sahf + jae @f + push edi esi + mov eax,[edi] + lea esi,[eax+Figure.MinY] + lea edi,[ebx+Object.MinY] + movsd + movsd + pop esi edi + @@: + add edi,4 + loop .cycle3 + .cycle3end: + + ;found max coord X + mov ecx,[ebx+Object.FigCount] + jecxz .cycle4end + mov edi,[ebx+Object.FigData] + ;copy first min X + mov eax,[edi] + fld qword[eax+Figure.MinX] + fadd qword[eax+Figure.SizeX] + fstp qword[ebx+Object.SizeX] + dec ecx + jecxz .cycle4end +align 4 + .cycle4: + add edi,4 + mov eax,[edi] + or eax,eax + jz @f + cmp [eax+Figure.PoiCount],0 + je @f + fld qword[eax+Figure.MinX] + fadd qword[eax+Figure.SizeX] + fcomp qword[ebx+Object.SizeX] + fstsw ax + sahf + jbe @f + mov eax,[edi] + fld qword[eax+Figure.MinX] + fadd qword[eax+Figure.SizeX] + fstp qword[ebx+Object.SizeX] + @@: + loop .cycle4 + .cycle4end: + + ;found max coord Y + mov ecx,[ebx+Object.FigCount] + jecxz .cycle5end + mov edi,[ebx+Object.FigData] + ;copy first min Y + mov eax,[edi] + fld qword[eax+Figure.MinY] + fadd qword[eax+Figure.SizeY] + fstp qword[ebx+Object.SizeY] + dec ecx + jecxz .cycle5end +align 4 + .cycle5: + add edi,4 + mov eax,[edi] + or eax,eax + jz @f + cmp [eax+Figure.PoiCount],0 + je @f + fld qword[eax+Figure.MinY] + fadd qword[eax+Figure.SizeY] + fcomp qword[ebx+Object.SizeY] + fstsw ax + sahf + jbe @f + mov eax,[edi] + fld qword[eax+Figure.MinY] + fadd qword[eax+Figure.SizeY] + fstp qword[ebx+Object.SizeY] + @@: + loop .cycle5 + .cycle5end: + + ;found size X + fld qword[ebx+Object.SizeX] + fsub qword[ebx+Object.MinX] + fstp qword[ebx+Object.SizeX] + ;found size Y + fld qword[ebx+Object.SizeY] + fsub qword[ebx+Object.MinY] + fstp qword[ebx+Object.SizeY] + + ;*** Calculate scale *** + fld1 + fstp qword[ebx+Object.WScale] ;set default scale + + fld qword[ebx+Object.SizeX] + ftst + fstsw ax + sahf + jne .els_0 ;if (SizeX == 0.0) + ffree st0 + fincstp + jmp .els_1 + .els_0: ;else if (SizeX != 0.0) + fild dword[buf_0.w] + fisub dword[graf_margin_left] + fisub dword[graf_margin_right] + fxch st1 + fdivp + fstp qword[ebx+Object.WScale] + .els_1: + + fld qword[ebx+Object.SizeY] + ftst + fstsw ax + sahf + jne .els_2 ;if (SizeY == 0.0) + ffree st0 + fincstp + jmp .els_3 + .els_2: ;else if (SizeY != 0.0) + fild dword[buf_0.h] + fisub dword[graf_margin_top] + fisub dword[graf_margin_bot] + fxch st1 + fdivp + fcom qword[ebx+Object.WScale] + fstsw ax + sahf + jbe @f + ffree st0 + fincstp + jmp .els_3 + @@: + fstp qword[ebx+Object.WScale] + .els_3: + + fld1 + fstp qword[ebx+Figure.MScale] + mov dword[ebx+Figure.MCentrX],0 + mov dword[ebx+Figure.MCentrY],0 + ret +endp + +;input: +; esi - input description text +; pfig - pointer to figure struct +;output: +; esi - output description text +align 4 +proc FigureInit uses eax ebx ecx edx edi, pfig:dword + mov ebx,FigData ; temp struct + mov [ebx+Figure.OType],'Fig' + mov edi,ebx + add edi,Figure.Caption + stdcall txt_load_line,32 + + xor eax,eax + mov [ebx+Figure.PoiCount],eax + mov [ebx+Figure.PoiData],eax + cmp byte[esi],'X' + jne .end0 + stdcall get_max_points + mov [ebx+Figure.PoiCount],eax + or eax,eax + jz .end0 + mov ecx,eax + imul eax,sizeof.Point + stdcall mem.Alloc,eax + mov [ebx+Figure.PoiData],eax + or eax,eax + jz .err_init + mov edi,eax +align 4 + .cycle0: + stdcall PointInit,edi + or eax,eax + jz .cycle0end + add edi,sizeof.Point + loop .cycle0 + .cycle0end: + or ecx,ecx + jz .end1 + ;уменьшаем объем памяти выделенный для точек + sub [ebx+Figure.PoiCount],ecx + mov eax,[ebx+Figure.PoiCount] + imul eax,sizeof.Point + stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax + mov [ebx+Figure.PoiData],eax + jmp .end1 + .err_init: + notify_window_run txt_err_2 + .end0: + ;command + stdcall txt_next_line, 80 + cmp byte[esi],13 + jne @f + ;if null line + inc esi + cmp byte[esi],10 + jne .end2 + inc esi + .end2: + mov dword[edi],(10 shl 8)+13 ;new line + @@: + stdcall add_object_in_list,ebx,[pfig] + jmp .end_f + .end1: + ;coords + stdcall add_object_in_list,ebx,[pfig] + or eax,eax + jz .end_f + stdcall FigCalculateSizes,eax,1 + .end_f: + ret +endp + +;input: +; esi - pointer to file +;output: +; eax - max lines in file +align 4 +proc get_max_lines uses esi + xor eax,eax + .cycle0: + cmp byte[esi],13 + jne @f + inc eax + @@: + inc esi + cmp byte[esi],0 + jne .cycle0 + ret +endp + +;input: +; esi - pointer to file +;output: +; eax - max point coords in file +align 4 +proc get_max_points uses esi + xor eax,eax + .cycle0: + cmp word[esi],' Y' + jne @f + inc eax + @@: + inc esi + cmp byte[esi+1],0 + jne .cycle0 + ret +endp + +;input: +; opt_calc - если 0 - пересчитать масштаб фигуры, +; 1 - пересчитать размеры и масштаб фигуры +align 4 +proc FigCalculateSizes uses eax ebx ecx edi esi, pfig:dword, opt_calc:dword + mov ebx,[pfig] + or ebx,ebx + jz .end_f + + finit + bt dword[opt_calc],0 + jnc .calc_scale + + ;*** Calculate sizes *** + mov esi,[ebx+Figure.PoiData] + or esi,esi + jz .end_f + + lea esi,[esi+Point.CoordX] + lea edi,[ebx+Figure.MinX] + movsd + movsd ;Figure.MinX = Point[0].CoordX + sub esi,8 + lea edi,[ebx+Figure.SizeX] + movsd + movsd ;Figure.SizeX = Point[0].CoordX + mov esi,[ebx+Figure.PoiData] + lea esi,[esi+Point.CoordY] + lea edi,[ebx+Figure.MinY] + movsd + movsd ;Figure.MinY = Point[0].CoordY + sub esi,8 + lea edi,[ebx+Figure.SizeY] + movsd + movsd ;Figure.SizeY = Point[0].CoordY + + ;found min coord X + mov ecx,[ebx+Figure.PoiCount] + jecxz .cycle2end + mov edi,[ebx+Figure.PoiData] +align 4 + .cycle2: + fld qword[edi+Point.CoordX] + fcomp qword[ebx+Figure.MinX] + fstsw ax + sahf + ja @f + push edi esi + lea esi,[edi+Point.CoordX] + lea edi,[ebx+Figure.MinX] + movsd + movsd + pop esi edi + @@: + add edi,sizeof.Point + loop .cycle2 + .cycle2end: + + ;found min coord Y + mov ecx,[ebx+Figure.PoiCount] + jecxz .cycle3end + mov edi,[ebx+Figure.PoiData] +align 4 + .cycle3: + fld qword[edi+Point.CoordY] + fcomp qword[ebx+Figure.MinY] + fstsw ax + sahf + ja @f + push edi esi + lea esi,[edi+Point.CoordY] + lea edi,[ebx+Figure.MinY] + movsd + movsd + pop esi edi + @@: + add edi,sizeof.Point + loop .cycle3 + .cycle3end: + + ;found max coord X + mov ecx,[ebx+Figure.PoiCount] + jecxz .cycle4end + mov edi,[ebx+Figure.PoiData] +align 4 + .cycle4: + fld qword[edi+Point.CoordX] + fcomp qword[ebx+Figure.SizeX] + fstsw ax + sahf + jbe @f + push edi esi + lea esi,[edi+Point.CoordX] + lea edi,[ebx+Figure.SizeX] + movsd + movsd + pop esi edi + @@: + add edi,sizeof.Point + loop .cycle4 + .cycle4end: + + ;found max coord Y + mov ecx,[ebx+Figure.PoiCount] + jecxz .cycle5end + mov edi,[ebx+Figure.PoiData] +align 4 + .cycle5: + fld qword[edi+Point.CoordY] + fcomp qword[ebx+Figure.SizeY] + fstsw ax + sahf + jbe @f + push edi esi + lea esi,[edi+Point.CoordY] + lea edi,[ebx+Figure.SizeY] + movsd + movsd + pop esi edi + @@: + add edi,sizeof.Point + loop .cycle5 + .cycle5end: + + ;found size X + fld qword[ebx+Figure.SizeX] + fsub qword[ebx+Figure.MinX] + fstp qword[ebx+Figure.SizeX] + ;found size Y + fld qword[ebx+Figure.SizeY] + fsub qword[ebx+Figure.MinY] + fstp qword[ebx+Figure.SizeY] + + ;*** Calculate scale *** +align 4 + .calc_scale: + mov dword[ebx+Figure.MCentrX],0 + mov dword[ebx+Figure.MCentrY],0 + fld1 + fst qword[ebx+Figure.MScale] ;??? + fstp qword[ebx+Figure.WScale] ;set default scale + + fld qword[ebx+Figure.SizeX] + ftst + fstsw ax + sahf + jne .els_0 ;if (SizeX == 0.0) + ffree st0 + fincstp + jmp .els_1 + .els_0: ;else if (SizeX != 0.0) + fild dword[buf_0.w] + fisub dword[graf_margin_left] + fisub dword[graf_margin_right] + fxch st1 + fdivp + fstp qword[ebx+Figure.WScale] + .els_1: + + fld qword[ebx+Figure.SizeY] + ftst + fstsw ax + sahf + jne .els_2 ;if (SizeY == 0.0) + ffree st0 + fincstp + jmp .els_3 + .els_2: ;else if (SizeY != 0.0) + fild dword[buf_0.h] + fisub dword[graf_margin_top] + fisub dword[graf_margin_bot] + fxch st1 + fdivp + fcom qword[ebx+Figure.WScale] + fstsw ax + sahf + jbe @f + ffree st0 + fincstp + jmp .els_3 + @@: + fstp qword[ebx+Figure.WScale] + .els_3: + + .end_f: + ret +endp + +;input: +; esi - input description text +; ppoi - pointer to point struct +;output: +; eax - 0 (if error init) or 1 +; esi - output description text +align 4 +proc PointInit uses ebx ecx edi, ppoi:dword + mov ecx,64 ;защита от зацикливания + @@: + lodsb + cmp al,' ' + jne @f + loop @b + @@: + dec esi + cmp byte[esi],'X' + jne .err_init + inc esi + stdcall conv_str_to_int, esi + mov ebx,[ppoi] + + ;Data_String <- esi + push esi + mov ecx,32 + mov edi,esi + @@: + lodsb + or al,al + jz @f + cmp al,' ' + je @f + cmp al,13 + je @f + loop @b + @@: + mov esi,edi + sub ecx,32 + neg ecx + mov edi,Data_String + rep movsb + mov byte[edi],0 + pop esi + stdcall String_to_DoubleFloat + ;Data_Double -> Point.CoordX + push esi + mov esi,Data_Double + lea edi,[ebx+Point.CoordX] + movsd + movsd + pop esi + + push edi + mov al,'Y' + mov ecx,80 + mov edi,esi + repne scasb + mov esi,edi + pop edi + ;Data_String <- esi + push esi + mov ecx,32 + mov edi,esi + @@: + lodsb + or al,al + jz @f + cmp al,' ' + je @f + cmp al,13 + je @f + loop @b + @@: + mov esi,edi + sub ecx,32 + neg ecx + mov edi,Data_String + rep movsb + mov byte[edi],0 + pop esi + stdcall String_to_DoubleFloat + ;Data_Double -> Point.CoordY + push esi + mov esi,Data_Double + lea edi,[ebx+Point.CoordY] + movsd + movsd + pop esi + + stdcall txt_next_line, 80 + jmp @f + .err_init: + xor eax,eax + jmp .end_f + @@: + xor eax,eax + inc eax + .end_f: + ret +endp + +;input: +; buffer - добавляемые данные +; pfig - указатель на добавленную фигуру (для контроля со стороны родительского объекта) +;output: +; eax - object data pointer +align 4 +proc add_object_in_list uses ebx ecx edi esi, buffer:dword, pfig:dword + mov ebx,[pfig] + or ebx,ebx + jz @f + stdcall mem.Alloc,sizeof.Figure + mov [ebx],eax + mov ecx,sizeof.Figure + mov edi,eax + mov esi,[buffer] + rep movsb + @@: + ret +endp + +;description: +; функция для рисования выбранного объекта +align 4 +proc draw_obj2d, pobj:dword +locals + CentrX dd ? + CentrY dd ? +endl +pushad + mov ebx,[pobj] + stdcall [buf2d_clear], buf_0, [buf_0.color] + mov ecx,[ebx+Object.FigCount] + or ecx,ecx + jz .end_f + ;;jecxz .end_f + mov edi,[ebx+Object.FigData] + finit + fld qword[ebx+Object.SizeY] + fmul qword[ebx+Object.WScale] + fmul qword[ebx+Object.MScale] + fchs + fistp dword[CentrY] + mov eax,[CentrY] + sub eax,[graf_margin_top] + sub eax,[graf_margin_bot] + add eax,[buf_0.h] + sar eax,1 + add eax,[graf_margin_bot] ;_bot а не _top - в связи с тем что коорд. Y перевернута + add eax,[ebx+Object.MCentrY] + mov [CentrY],eax + fld qword[ebx+Object.SizeX] + fmul qword[ebx+Object.WScale] + fmul qword[ebx+Object.MScale] + fchs + fistp dword[CentrX] + mov edx,[CentrX] + sub edx,[graf_margin_left] + sub edx,[graf_margin_right] + add edx,[buf_0.w] + sar edx,1 + add edx,[graf_margin_left] + add edx,[ebx+Object.MCentrX] + mov [CentrX],edx +align 4 + .cycle0: + stdcall draw_fig2d_litl, buf_0,ebx,[edi],0,edx,eax + add edi,4 + loop .cycle0 + stdcall [buf2d_flip_v], buf_0 + + bt dword[opt_draw],0 + jnc .end_f + ; draw min & sizes + mov word[NumberSymbolsAD],8 + stdcall mem_copy, txt_buf,txt_size_x,20 + fld qword[ebx+Object.SizeX] + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall str_cat,txt_buf,txt_n + stdcall str_cat,txt_buf,txt_size_y + fld qword[ebx+Object.SizeY] + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,23,0 + + fld qword[ebx+Object.MinX] + fstp qword[Data_Double] + stdcall mem_copy, txt_buf,txt_min_x,20 + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall str_cat,txt_buf,txt_n + stdcall str_cat,txt_buf,txt_min_y + fld qword[ebx+Object.MinY] + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,3,0 + .end_f: +popad + ret +endp + +;input: +; pbuf - pointer to buffer 2d +;description: +; функция для рисования объекта по частям +align 4 +proc draw_fig2d_litl, pbuf:dword, pobj:dword, pfig:dword, Scale:dword, CentrX:dword, CentrY:dword +locals + PervX dd 0 ;pervios point coord X + PervY dd 0 ;pervios point coord Y + GrafX dd ? ;active point coord X + GrafY dd ? ;active point coord Y +endl +pushad + mov ebx,[pfig] + test ebx,ebx + jz .end_f + mov ecx,[ebx+Figure.PoiCount] + ;;jecxz .end_f + test ecx,ecx + jz .end_f + mov edi,[ebx+Figure.PoiData] + mov edx,[pobj] + + fld1 + mov eax,[Scale] + or eax,eax + jnz @f + lea eax,[edx+Object.MScale] + fmul qword[eax] + lea eax,[edx+Object.WScale] + @@: + fmul qword[eax] +align 4 + .cycle0: + fld qword[edi+Point.CoordX] + fsub qword[edx+Object.MinX] + fmul st0,st1 + fiadd dword[CentrX] + fistp dword[ebp-8] + fld qword[edi+Point.CoordY] + fsub qword[edx+Object.MinY] + fmul st0,st1 + fiadd dword[CentrY] + fistp dword[ebp-4] + stdcall [buf2d_set_pixel], [pbuf], [GrafX],[GrafY], 0xff0000 + cmp ecx,[ebx+Figure.PoiCount] + je @f + stdcall [buf2d_line_sm], [pbuf], [PervX],[PervY], [GrafX],[GrafY], 0x80 + ;sub esp,24 + ;call [buf2d_line] + stdcall [buf2d_line], [pbuf], [PervX],[PervY], [GrafX],[GrafY], 0x80 + @@: + mov eax,[GrafX] + mov [PervX],eax + mov eax,[GrafY] + mov [PervY],eax + add edi,sizeof.Point + ;;loop .cycle0 + dec ecx + jnz .cycle0 + ffree st0 + fincstp + + .end_f: +popad + ret +endp + +;description: +; функция для рисования выбранной фигуры +align 4 +proc draw_fig2d, pfig:dword +locals + n dd 0 + col_lin dd 0 ;цвет линий фигуры + CentrX dd ? + CentrY dd ? + PervX dd 0 ;pervios point coord X + PervY dd 0 ;pervios point coord Y + GrafX dd ? ;active point coord X + GrafY dd ? ;active point coord Y + old_tl dd 0 ;old text coord X0 + old_tt dd 0 ;old text coord Y0 + old_tw dd 0 ;old text coord X1 + old_th dd 0 ;old text coord Y1 + new_tl dd 0 ;new text coord X0 + ;new_tt dd 0 ;new text coord Y0 + new_tw dd 0 ;new text coord X1 + ;new_th dd 0 ;new text coord Y1 +endl +pushad + stdcall [buf2d_clear], buf_0, [buf_0.color] + mov ebx,[pfig] + test ebx,ebx + jz .end_f + mov ecx,[ebx+Figure.PoiCount] + ;;jecxz .end_f + test ecx,ecx + jz .end_f + mov edi,[ebx+Figure.PoiData] + finit + fld qword[ebx+Figure.SizeY] + fmul qword[ebx+Figure.WScale] + fmul qword[ebx+Figure.MScale] + fchs + fistp dword[CentrY] + mov eax,[CentrY] + sub eax,[graf_margin_top] + sub eax,[graf_margin_bot] + add eax,[buf_0.h] + sar eax,1 + add eax,[graf_margin_bot] + add eax,[ebx+Figure.MCentrY] + mov [CentrY],eax + ;CentrY = (-(Figure.SizeY * Figure.WScale) - graf_margin_top - graf_margin_bot + buf_0.h) / 2 + graf_margin_bot + fld qword[ebx+Figure.SizeX] + fmul qword[ebx+Figure.WScale] + fmul qword[ebx+Figure.MScale] + fchs + fistp dword[CentrX] + mov eax,[CentrX] + sub eax,[graf_margin_left] + sub eax,[graf_margin_right] + add eax,[buf_0.w] + sar eax,1 + add eax,[graf_margin_left] + add eax,[ebx+Figure.MCentrX] + mov [CentrX],eax + ;CentrX = (-(Figure.SizeX * Figure.WScale) - graf_margin_left - graf_margin_right + buf_0.w) / 2 + graf_margin_left + +align 4 + .cycle0: + fld qword[edi+Point.CoordX] + fsub qword[ebx+Figure.MinX] + fmul qword[ebx+Figure.WScale] + fmul qword[ebx+Figure.MScale] + fiadd dword[CentrX] + fistp dword[GrafX] + ;GrafX = (Point.CoordX - Figure.MinX) * Figure.WScale + CentrX + fld qword[edi+Point.CoordY] + fsub qword[ebx+Figure.MinY] + fmul qword[ebx+Figure.WScale] + fmul qword[ebx+Figure.MScale] + fiadd dword[CentrY] + fisub dword[buf_0.h] ;invert coord Y + fchs + fistp dword[GrafY] + ;GrafY = -((Point.CoordY - Figure.MinY) * Figure.WScale + CentrY - buf_0.h) + + stdcall [buf2d_set_pixel], buf_0, [GrafX],[GrafY], 0xff0000 + mov dword[col_lin],0x80 + cmp ecx,[ebx+Figure.PoiCount] + je @f + stdcall [buf2d_line_sm], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin] + stdcall [buf2d_line], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin] + @@: + mov eax,[GrafX] + mov [PervX],eax + mov edx,[GrafY] + mov [PervY],edx + add edi,sizeof.Point + + bt dword[opt_draw],0 + jnc .end0 + ; draw number points + ;mov eax,[GrafX] + ;mov edx,[GrafY] + add eax,2 + add edx,2 + push eax edi + mov eax,[n] + mov edi,txt_buf + stdcall convert_int_to_str,20 + pop edi eax + + inc dword[n] + ;calculate new text coords + mov [new_tl],eax + mov esi,eax + stdcall str_len,txt_buf + imul eax,[buf_1.w] + add eax,esi + mov [new_tw],eax + ;rect compare coords + cmp [old_tl],eax + jg .no_comp + cmp [old_tw],esi + jl .no_comp + ;calculate new text coord Y1 + mov esi,edx + add esi,[font_h] + cmp [old_tt],esi + jg .no_comp + cmp [old_th],edx + ;jl .no_comp + ;jmp .end0 + jge .end0 + .no_comp: + mov eax,[new_tl] + mov [old_tl],eax + mov eax,[new_tw] + mov [old_tw],eax + mov [old_tt],edx + add edx,[font_h] + mov [old_th],edx + stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,[old_tl],[old_tt],0x000000 + .end0: + dec ecx + jnz .cycle0 + + bt dword[opt_draw],0 + jnc .end_f + ; draw min & sizes + mov word[NumberSymbolsAD],8 + stdcall mem_copy, txt_buf,txt_size_x,20 + fld qword[ebx+Figure.SizeX] + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall str_cat,txt_buf,txt_n + stdcall str_cat,txt_buf,txt_size_y + fld qword[ebx+Figure.SizeY] + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,23,0 + + fld qword[ebx+Figure.MinX] + fstp qword[Data_Double] + stdcall mem_copy, txt_buf,txt_min_x,20 + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall str_cat,txt_buf,txt_n + stdcall str_cat,txt_buf,txt_min_y + fld qword[ebx+Figure.MinY] + fstp qword[Data_Double] + call DoubleFloat_to_String + call String_crop_0 + stdcall str_cat,txt_buf,Data_String + stdcall [buf2d_draw_text], buf_0, buf_1,txt_buf,3,3,0 + .end_f: +popad + ret +endp + +align 4 +proc mouse_left_d uses eax ebx + call buf_get_mouse_coord + cmp eax,-1 + je .end_f + mov [mouse_down_x],eax + mov [mouse_down_y],ebx + .end_f: + ret +endp + +align 4 +proc mouse_left_u uses eax ebx ecx + call buf_get_mouse_coord + cmp eax,-1 + je .end_f + sub eax,[mouse_down_x] + sub ebx,[mouse_down_y] + mov ecx,ObjData + add [ecx+Figure.MCentrX],eax + sub [ecx+Figure.MCentrY],ebx + mov dword[offs_last_timer],0 + .end_f: + ret +endp diff --git a/programs/other/cnc_control/toolbar.png b/programs/other/cnc_control/toolbar.png new file mode 100644 index 0000000000000000000000000000000000000000..aa9bc19e3f84f7c00be4fba7968347b64fddb12e GIT binary patch literal 1303 zcmV+y1?c*TP)N2bZe?^J zG%hhr@5TQB00fswL_t(oN6lAFXdP7){$?_XNvx@D6>Zckv@Rr2i3@|`MntjIc2N-& zK?Jdgh&y$oD_wMzR%wIAAGF%KP*IH3YDE_*1`4fcDcZDY+9al8l9%^h=FPk}Gk3;w zZaU+<`FkUiLN6TV-MQ!c?sv|)=O&~4G~szDFqFImW8ZxSvuqR?)C;c2VPALZuqSs*lrs%25;WH4!87OEuB@@ zhAJBP>QD)tDe!%JcEfQs2v3Fb`TimAkw-T|QMCZf1n$CVd~xhXIJO{jU^@;3nd1ob z@7NVkYr++P(}1dZa_2TOr8*522A;V4Tuj5>Z?A27ryO{Hm$!ZEdUUq8OYo7S%hJJh zJ=)EMBV5{@RnU`+74SPpcyQ^dxvmS(u0vH_oIm?FOuGl$2A65x7TQSx__VkVU^nP# z;`fvD`0)EWG>*};O{j{6le5?0h7B%Mi&Qu(O5||rfT%&#P1uHk*^7&K@5hbU@!DYu znrYH}Wh9*eCpEGN5$GY=4F*+P9SVDv8XfUj+P_sH<*d3JM zH8?ZlV(9DHz)#uz=F3#C3hE6Ddd-Bco2cprD%F~_D$RA8*UX0WQK=vY$2rWEk*k^h zD@Xj7GC4U}>^{gMcKK$=}5@JV7xRH#&0cwWz}!XFbR zx;xs?)gCu~&+Fk)_$0RMM$UFxBe9aqX7WoFJ}1$m-%>#o5S^>Pyf_ZF`RV2}-U{fi zXNHi6~J_qB&qj-A9Gqxd<9Ka2-iNGZFWvt<0{0;nCJNVKC99T#oIaW z=YLvgh5xX$B>3j=&tNO0;MYSvsU$5G_&cYO$gj36iA=y?e++D`V*A7Q2lId+?9}Qo zg-LRUP$-F6idH8FSvzoo{rp4|$hh1&NCM|3NCPuL;jj1HAzZdH{tNsD6i6hmYqkIY N002ovPDHLkV1mO3U@-sy literal 0 HcmV?d00001