Subversion Repositories Kolibri OS

Rev

Rev 7360 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7360 IgorA 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 ;очистка списка объектов
7663 IgorA 304
		and dword[tree1.style],not tl_cursor_pos_limited
7360 IgorA 305
		mov dword[offs_last_timer],0
306
 
307
		stdcall ObjectCreate,ObjData
7663 IgorA 308
		or dword[tree1.style], tl_cursor_pos_limited
7360 IgorA 309
		stdcall [tl_cur_beg], tree1
310
 
311
		mov dword[offs_last_timer],0 ;для обновления блока в таймере
312
		pop esi edi ecx eax
313
		jmp .exit
314
	.end_save:
315
 
316
	cmp ah,1
317
	jne still_n_file.end
318
.exit:
319
	mov byte[wnd_n_file],0 ;обнуляем счетчик окон
320
	mcall SF_TERMINATE_PROCESS ;выход из программы
321
 
322
align 4
323
proc ObjectCreate, pobj:dword
324
pushad
325
	mov ebx,[pobj]
326
	mov [ebx+Object.OType],'Obj'
327
	mov edi,ebx
328
	add edi,Object.Caption
329
	mov dword[edi],'CNC'
330
 
331
	mov eax,7 ;max lines
332
	mov [ebx+Object.FigCount],eax
333
	mov ecx,eax
334
 
335
	shl eax,2
336
	stdcall mem.Alloc,eax
337
	mov [ebx+Object.FigData],eax
338
	push ecx
339
		mov edi,eax
340
		xor eax,eax
341
		rep stosd ;clear memory
342
	pop ecx
343
 
344
	stdcall add_object_in_list,0,0,ebx,0
345
	;eax -> pointer to object node
346
	mov edi,[ebx+Object.FigData]
347
 
348
	mov esi,txt_00
349
	stdcall FigureInit,FigData,edi
350
	add edi,4
351
	mov esi,txt_01
352
	stdcall FigureInit,FigData,edi
353
	add edi,4
354
	mov esi,txt_02
355
	stdcall FigureInit,FigData,edi
356
	add edi,4
357
	mov esi,txt_03
358
	stdcall FigureInit,FigData,edi
359
	add edi,4
360
	mov esi,txt_04 ;X__ Y__
361
	stdcall FigureInit,FigData,edi
362
	; *** create new points ***
363
	mov edx,[edi]
364
	cmp [opt_gr1],opt1
365
	jne .rect
366
		;circle
367
		fld qword[NOptCoordY1]
368
		fistp dword[edx+Figure.PoiCount]
369
		inc dword[edx+Figure.PoiCount]
370
		mov eax,[edx+Figure.PoiCount]
371
		imul eax,sizeof.Point
372
		stdcall mem.ReAlloc,[edx+Figure.PoiData],eax
373
		mov [edx+Figure.PoiData],eax
374
 
375
		;init points
376
		fldpi
377
		fadd st0,st0
378
		fdiv qword[NOptCoordY1]
379
		fldz
380
		;st0 - angle (=0)
381
		;st1 - delta angle (=pi/slices)
382
 
383
		mov ecx,[edx+Figure.PoiCount]
384
		cmp ecx,3
385
		jge @f
386
			mov ecx,3
387
		@@:
388
		mov edx,[edx+Figure.PoiData]
389
		add edx,Point.CoordX
390
		.cycle0:
391
			add edx,sizeof.Point
392
			fadd st0,st1 ;angle += delta angle
393
 
394
			fld st0
395
			fcos
396
			fmul qword[NOptCoordX1] ;st0 = cos(angle) * radius
397
			fadd qword[NOptCoordX0]
398
			fstp qword[edx]
399
			fld st0
400
			fsin
401
			fmul qword[NOptCoordX1] ;st0 = sin(angle) * radius
402
			fadd qword[NOptCoordY0]
403
			fstp qword[edx+8]
404
			loop .cycle0
405
		ffree st0
406
		fincstp
407
		ffree st0
408
		fincstp
409
		jmp .end0
410
	.rect:
411
		;rect
412
		mov eax,5
413
		mov dword[edx+Figure.PoiCount],eax
414
		imul eax,sizeof.Point
415
		stdcall mem.ReAlloc,[edx+Figure.PoiData],eax
416
		mov [edx+Figure.PoiData],eax
417
		;init points
418
		push edi
419
		mov ecx,[edx+Figure.PoiData]
420
		;p1
421
		add ecx,sizeof.Point
422
		lea edi,[ecx+Point.CoordX]
423
		mov esi,NOptCoordX1
424
		movsd
425
		movsd
426
		mov esi,NOptCoordY0
427
		movsd
428
		movsd
429
		;p2
430
		add ecx,sizeof.Point
431
		lea edi,[ecx+Point.CoordX]
432
		mov esi,NOptCoordX1
433
		movsd
434
		movsd
435
		mov esi,NOptCoordY1
436
		movsd
437
		movsd
438
		;p3
439
		add ecx,sizeof.Point
440
		lea edi,[ecx+Point.CoordX]
441
		mov esi,NOptCoordX0
442
		movsd
443
		movsd
444
		mov esi,NOptCoordY1
445
		movsd
446
		movsd
447
		;p4
448
		add ecx,sizeof.Point
449
		lea edi,[ecx+Point.CoordX]
450
		mov esi,NOptCoordX0
451
		movsd
452
		movsd
453
		mov esi,NOptCoordY0
454
		movsd
455
		movsd
456
		pop edi
457
	.end0:
458
	stdcall found_parent_obj,[edi] ;get figure number in ecx
459
	stdcall figure_update_coords,ObjData,ecx
460
 
461
	add edi,4
462
	mov esi,txt_05
463
	stdcall FigureInit,FigData,edi
464
	add edi,4
465
	mov esi,txt_06
466
	stdcall FigureInit,FigData,edi
467
 
468
	stdcall ObjCalculateScale,ebx
469
popad
470
	ret
471
endp
472
 
473
align 4
474
proc get_n_file_opt uses eax
475
	;загрузка координат в editbox-ы
476
	mov word[NumberSymbolsAD],3
477
	finit
478
	fld qword[NOptCoordX0]
479
	fstp qword[Data_Double]
480
	call DoubleFloat_to_String
481
	call String_crop_0
482
	stdcall [edit_box_set_text], edit4, Data_String
483
	fld qword[NOptCoordY0]
484
	fstp qword[Data_Double]
485
	call DoubleFloat_to_String
486
	call String_crop_0
487
	stdcall [edit_box_set_text], edit5, Data_String
488
	fld qword[NOptCoordX1]
489
	fstp qword[Data_Double]
490
	call DoubleFloat_to_String
491
	call String_crop_0
492
	stdcall [edit_box_set_text], edit6, Data_String
493
	fld qword[NOptCoordY1]
494
	fstp qword[Data_Double]
495
	call DoubleFloat_to_String
496
	call String_crop_0
497
	stdcall [edit_box_set_text], edit7, Data_String
498
	fld qword[NOptCoordZ0]
499
	fstp qword[Data_Double]
500
	call DoubleFloat_to_String
501
	call String_crop_0
502
	stdcall [edit_box_set_text], edit8, Data_String
503
	fld qword[NOptCoordZ1]
504
	fstp qword[Data_Double]
505
	call DoubleFloat_to_String
506
	call String_crop_0
507
	stdcall [edit_box_set_text], edit9, Data_String
508
	;
509
	;stdcall [edit_box_draw], edit4
510
	;stdcall [edit_box_draw], edit5
511
	ret
512
endp
513
 
514
align 4
515
proc timer_funct_n_file uses eax
516
	;просматриваем выделенную координату
517
	mov eax,[opt_gr1]
518
	cmp eax,[last_opt]
519
	je @f
520
		mov eax,[opt_gr1]
521
		mov [last_opt],eax
522
		call red_win_n_file
523
	@@:
524
	ret
525
endp
526
 
527
capt_coord_x0 db 'X0:',0
528
capt_coord_y0 db 'Y0:',0
529
capt_coord_z0 db 'Z0:',0
530
capt_coord_x1 db 'X1:',0
531
capt_coord_y1 db 'Y1:',0
532
capt_coord_z1 db 'Z1:',0
533
capt_coord_r  db 'R:',0
534
capt_coord_s  db 'S:',0
535
 
536
edit4 edit_box 80, 24, 28, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 34, string4, mouse_dd, 0
537
edit5 edit_box 80, 24, 46, 0xd0d0ff, 0xff, 0x80ff, 0, 0x8000, 34, string5, mouse_dd, 0
538
edit6 edit_box 80, 24, 64, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 34, string6, mouse_dd, 0
539
edit7 edit_box 80, 24, 82, 0xd0d0ff, 0xff, 0x80ff, 0, 0x8000, 34, string7, mouse_dd, 0
540
edit8 edit_box 80, 24, 100, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 34, string8, mouse_dd, 0
541
edit9 edit_box 80, 24, 118, 0xd0d0ff, 0xff, 0x80ff, 0, 0x8000, 34, string9, mouse_dd, 0
542
editboxes_end_nf:
543
 
544
string4 rb 34
545
string5 rb 34
546
string6 rb 34
547
string7 rb 34
548
string8 rb 34
549
string9 rb 34
550
 
551
align 4
552
last_opt dd opt1 ;for timer
553
opt_gr1 dd opt1
554
 
555
opt1 option_box opt_gr1, 115,28,6,12,0xd0d0ff, 0xff, 0x80ff,txt_circle,txt_circle.end-txt_circle
556
opt2 option_box opt_gr1, 115,46,6,12,0xd0d0ff, 0xff, 0x80ff,txt_rect,txt_rect.end-txt_rect
557
 
558
align 4
559
opt_grlist1 dd opt1,opt2,0 ;end option group
560
 
561
txt_00 db ';PCB graving',0
562
txt_01: db 'G0 M3 X0 Y0 Z'
563
.z: rb 12
564
txt_02: db 'G0 X'
565
.x: rb 50 ;X__ Y__ Z__
566
txt_03: db 'G1 F100 Z'
567
.z: rb 12
568
txt_04: db 'X'
569
.x: rb 30 ;X__ Y__
570
txt_05: db 'G0 Z'
571
.z: rb 12
572
txt_06: db 'G0 M5 X0 Y0 Z'
573
.z: rb 12
574
 
575
if lang eq ru
576
capt_n_file db 'Создать новый файл',0
577
capt_sel_fig db 'Выберите фигуру:',0
578
txt_circle: db 'Окружность'
579
.end: db 0
580
txt_rect: db 'Прямоугольник'
581
.end: db 0
582
else
583
capt_n_file db 'Create new file',0
584
capt_sel_fig db 'Select figure:',0
585
txt_circle: db 'Circle'
586
.end: db 0
587
txt_rect: db 'Rectangle'
588
.end: db 0
589
end if