Subversion Repositories Kolibri OS

Rev

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