Subversion Repositories Kolibri OS

Rev

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

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