Develop and Download Open Source Software

Browse Subversion Repository

Contents of /graphic.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Mon Nov 7 12:03:00 2011 UTC (12 years, 4 months ago) by shiraishikazuo
File MIME type: text/x-pascal
File size: 108004 byte(s)


1 unit graphic;
2 {$IFDEF FPC}
3 {$MODE DELPHI}{$H+}
4 {$ENDIF}
5
6 (***************************************)
7 (* Copyright (C) 2009, SHIRAISHI Kazuo *)
8 (***************************************)
9
10
11
12 {********}
13 interface
14 {********}
15 uses Graphics,
16 textfile,struct,variabl;
17
18 type
19 TAskStatus=Class(Tstatement)
20 Status:TVariable;
21 //procedure StatusInit;
22 destructor destroy;override;
23 function Code:Ansistring;override;
24 function AskCode:Ansistring;virtual;abstract;
25 end;
26 function ASKst(prev,eld:TStatement):TAskStatus;
27
28 function PixelX(x:extended):extended;
29 function PixelY(x:extended):extended;
30 function WindowX(x:extended):extended;
31 function WindowY(x:extended):extended;
32
33
34 var
35 SetTextJustifySt:function(prev,eld:TStatement):TStatement;
36 PlotTextst: function(prev,eld:TStatement):TStatement;
37
38
39 function MATPLOTst(prev,eld:TStatement):TStatement;
40 function MATLOCATEst(prev,eld:TStatement):TStatement;
41 function MSLINEst(prev,eld:TStatement):TStatement;
42
43
44
45 {************}
46 implementation
47 {************}
48 uses Types,Forms,Dialogs,SysUtils,
49 MyUtils,base,base0,objlist,float,affine,texthand,
50 express, mat,setask,helpctex,
51 draw,sconsts,confopt,paintfrm,graphsys,colordlg,locatefrm,
52 graphlib;
53
54 {********}
55 {graphics}
56 {********}
57 type
58 setprocedure=procedure(x:double; insideofWhen:boolean);
59
60
61 type
62 TCustomSetWindow=class(TStatement)
63 x1,x2,y1,y2:TPrincipal;
64 destructor destroy;override;
65 //procedure exec;override;
66 function codesub:ansistring;
67 end;
68
69 TSetWindow=class(TCustomSetWindow)
70 constructor create(prev,eld:TStatement);
71 function Code:AnsiString;override;
72 end;
73
74 TSetDeviceViewPort=class(TSetWindow)
75 //procedure exec;override;
76 //function execute(var l,r,b,t:extended):boolean;override;
77 function Code:AnsiString;override;
78 end;
79
80 TSetDeviceWindow=class(TSetDeviceViewport)
81 //procedure exec;override;
82 function Code:AnsiString;override;
83 end;
84
85 TSetViewPort=class(TSetDeviceViewport)
86 //procedure exec;override;
87 function Code:AnsiString;override;
88 end;
89
90
91 constructor TsetWindow.create(prev,eld:TStatement);
92 label
93 errorExit;
94 begin
95 inherited create(prev,eld);
96 graphmode:=true;
97 x1:=nexpression;
98 check(',',IDH_WINDOW);
99 x2:=nexpression;
100 check(',',IDH_WINDOW);
101 y1:=nexpression;
102 check(',',IDH_WINDOW);
103 y2:=nexpression;
104 end;
105
106 destructor TCustomSetWindow.destroy;
107 begin
108 x1.free;
109 x2.free;
110 y1.free;
111 y2.free;
112 inherited destroy
113 end;
114
115 (*
116 procedure TCustomSetWindow.exec;
117 var
118 l,r,b,t:extended;
119 begin
120 l:=x1.evalX;
121 r:=x2.evalX;
122 b:=y1.evalX;
123 t:=y2.evalX;
124 GraphLib.SetWindow(l,r,b,t,insideofWhen)
125 end;
126
127
128 procedure TSetViewPort.exec;
129 var
130 l,r,b,t:extended;
131 begin
132 l:=x1.evalX;
133 r:=x2.evalX;
134 b:=y1.evalX;
135 t:=y2.evalX;
136 GraphLib.SetViewPort(l,r,b,t,InsideOfWhen);
137 end;
138
139
140 procedure TSetDeviceWindow.exec;
141 var
142 l,r,b,t:extended;
143 begin
144 l:=x1.evalX;
145 r:=x2.evalX;
146 b:=y1.evalX;
147 t:=y2.evalX;
148 GraphLib.SetDeviceWindow(l,r,b,t,InsideOfWhen);
149 end;
150
151
152 procedure TSetDeviceViewPort.exec;
153 var
154 l,r,b,t:extended;
155 begin
156 l:=x1.evalX;
157 r:=x2.evalX;
158 b:=y1.evalX;
159 t:=y2.evalX;
160 GraphLib.SetDeviceViewPort(l,r,b,t,InsideOfWhen);
161 end;
162 *)
163
164 type
165 TSetColorMix=class(TStatement)
166 ColorIndex,Red,Green,Blue:TPrincipal;
167 constructor create(prev,eld:TStatement);
168 destructor destroy;override;
169 //procedure exec;override;
170 function code:ansistring;override;
171 end;
172
173
174
175
176 constructor TsetColorMix.create(prev,eld:TStatement);
177 begin
178 graphmode:=true;
179 inherited create(prev,eld);
180 Check('(',IDH_SET_COLOR_MIX);
181 ColorIndex:=nexpression;
182 check(')',IDH_SET_COLOR_MIX);
183 Red:=nexpression;
184 check(',',IDH_SET_COLOR_MIX);
185 Green:=nexpression;
186 check(',',IDH_SET_COLOR_MIX);
187 Blue:=nexpression;
188 end;
189
190 destructor TSetColorMix.destroy;
191 begin
192 ColorIndex.free;
193 Red.free;
194 Green.free;
195 Blue.free;
196 inherited destroy
197 end;
198
199
200 (*
201 procedure TSetColorMix.exec;
202 var
203 er,eg,eb:extended;
204 cc:longint;
205 r,g,b:byte;
206 begin
207 cc:=ColorIndex.evalInteger;
208 er:=Red.evalX ;
209 eg:=Green.evalX;
210 eb:=Blue.evalX;
211
212 SetColorMix(cc,r,g,b,insideofWhen)
213 end;
214 *)
215
216 type
217 TSET=class(TStatement)
218 exp:TPrincipal;
219 setprc:setprocedure;
220 idxmax:integer;
221 ercode:integer;
222 constructor create(prev,eld:TStatement; s:setprocedure; imax:integer; erc:integer);
223 constructor createColor(prev,eld:TStatement; s:setprocedure);
224 //procedure exec;override;
225 destructor destroy;override;
226 function code:ansistring;override;
227 end;
228
229 constructor TSet.create(prev,eld:TStatement; s:setprocedure; imax:integer; erc:integer);
230 begin
231 inherited create(prev,eld);
232 exp :=nexpression;
233 setprc:=s;
234 idxmax:=imax;
235 ercode:=erc;
236 end;
237
238 constructor TSet.createColor(prev,eld:TStatement; s:setprocedure);
239 begin
240 inherited create(prev,eld);
241 exp :=NSExpression;
242 setprc:=s;
243 idxmax:=255;
244 ercode:=11085;
245 end;
246
247
248 destructor TSet.destroy;
249 begin
250 exp.free;
251 inherited destroy
252 end;
253
254 (*
255 procedure TSet.exec;
256 var
257 s:ansistring;
258 color:longint;
259 x:double;
260 i:integer;
261 begin
262 if exp.kind<>'s' then
263 begin
264 x:=exp.evalX;
265 setprc(x,InsideOfWhen)
266 end
267 else
268 begin
269 s:=exp.evalS;
270 color:=GraphLib.ColorOfName(s,insideofWhen);
271 i:=MyPalette.ColorIndex(color);
272 if i>=0 then
273 setprc(i,insideOfWhen);
274 end;
275 end;
276 *)
277
278 type
279 TSetDrawMode=class(TStatement)
280 mode:char;
281 constructor create(prev,eld:TStatement);
282 //procedure exec;override;
283 function code:ansistring;override;
284 end;
285
286 constructor TSetDrawMode.create(prev,eld:TStatement);
287 begin
288 inherited create(prev,eld);
289 if (token='EXPLICIT')
290 or (token='HIDDEN')
291 or (token='MERGE')
292 or (token='XOR')
293 or (token='NOTXOR')
294 or (token='OVERWRITE') then
295 mode:=token[1]
296 else if token='MASK' then
297 mode:='A'
298 else
299 seterrIllegal(token,0);
300 gettoken;
301 end;
302
303
304 (*
305 procedure TSetDrawMode.exec;
306 begin
307 case mode of
308 'E': MyGraphSys.setHiddenDrawMode(false);
309 'H': MyGraphSys.setHiddenDrawMode(true) ;
310 'N': MyGraphSys.setRasterMode(pmNotXor) ;
311 'O': MyGraphSys.setRasterMode(pmCopy) ;
312 'A': MyGraphSys.setRasterMode(pmMask) ;
313 'M': MyGraphSys.setRasterMode(pmMerge) ;
314 'X': MyGraphSys.setRasterMode(pmXor) ;
315 end;
316 end;
317 *)
318 {SET TEXT HEIGHT}
319 type
320 TSetTextHeight=class(TStatement)
321 exp:TPrincipal;
322 constructor create(prev,eld:TStatement);
323 //procedure exec;override;
324 destructor destroy;override;
325 function code:ansistring;override;
326 end;
327
328 constructor TSetTextHeight.create(prev,eld:TStatement);
329 begin
330 inherited create(prev,eld);
331 exp :=nexpression;
332 end;
333
334 destructor TSetTextHeight.destroy;
335 begin
336 exp.free;
337 inherited destroy
338 end;
339
340 (*
341 procedure TSetTextHeight.exec;
342 var
343 x:extended;
344 begin
345 x:=exp.evalX;
346 SetTextHeight(x,InsideOfWhen);
347 end;
348 *)
349 {ask text height}
350
351 {SET TEXT ANGLE}
352 type
353 TSetTextAngle=class(TStatement)
354 exp:TPrincipal;
355 constructor create(prev,eld:TStatement);
356 //procedure exec;override;
357 destructor destroy;override;
358 function code:ansistring;override;
359 end;
360
361 constructor TSetTextAngle.create(prev,eld:TStatement);
362 begin
363 inherited create(prev,eld);
364 exp :=nexpression;
365 end;
366
367 destructor TSetTextAngle.destroy;
368 begin
369 exp.free;
370 inherited destroy
371 end;
372 (*
373 procedure TSetTextAngle.exec;
374 var
375 x:extended;
376 a:integer;
377 begin
378 x:=exp.evalX;
379 SetTextAngle(x,PUnit.Angledegrees)
380 end;
381 *)
382
383 type
384 TSetClip=class(TStatement)
385 exp:TPrincipal;
386 constructor create(prev,eld:TStatement);
387 //procedure exec;override;
388 destructor destroy;override;
389 function code:ansistring;override;
390 end;
391
392 constructor TSetClip.create(prev,eld:TStatement);
393 begin
394 inherited create(prev,eld);
395 exp :=sexpression;
396 end;
397
398 destructor TSetClip.destroy;
399 begin
400 exp.free;
401 inherited destroy
402 end;
403 (*
404 procedure TSetClip.exec;
405 begin
406 GraphLib.SetClip(exp.evalS, InsideOfWhen);
407 end;
408 *)
409 {SET TEXT Font}
410 type
411 TSetTextFont=class(TStatement)
412 exp1,exp2:TPrincipal;
413 constructor create(prev,eld:TStatement);
414 //procedure exec;override;
415 destructor destroy;override;
416 function code:ansistring;override;
417 end;
418
419 constructor TSetTextFont.create(prev,eld:TStatement);
420 begin
421 inherited create(prev,eld);
422 exp1 :=SExpression;
423 checktoken(',',IDH_GRAPH_EXT);
424 exp2:=NExpression;
425 end;
426
427 destructor TSetTextFont.destroy;
428 begin
429 exp1.free;
430 exp2.free;
431 inherited destroy
432 end;
433
434 (*
435 procedure TSetTextFont.exec;
436 var
437 s:ansistring;
438 x:double;
439 begin
440 s:=exp1.evalS;
441 x:=exp2.evalX;
442 SetTextFont(s,x);
443 end;
444 *)
445
446 {TSetTextBk}
447
448 type
449 TSetTextBk=class(TStatement)
450 exp:TPrincipal;
451 constructor create(prev,eld:TStatement);
452 //procedure exec;override;
453 destructor destroy;override;
454 function code:ansistring;override;
455 end;
456
457 constructor TSetTextBk.create(prev,eld:TStatement);
458 begin
459 inherited create(prev,eld);
460 exp :=sexpression;
461 end;
462
463 destructor TSetTextBk.destroy;
464 begin
465 exp.free;
466 inherited destroy
467 end;
468 (*
469 procedure TSetTextBk.exec;
470 var
471 s:string;
472 begin
473 GraphLib.SetTextBackGround(exp.evalS);
474 end;
475 *)
476
477 type
478 TSetAreaStyle=class(TSetTextBk)
479 //procedure exec;override;
480 function code:ansistring;override;
481 end;
482 (*
483 procedure TSetAreaStyle.exec;
484 begin
485 GraphLib.SetAreaStyle(exp.evalS);
486 end;
487 *)
488
489
490 type
491 TSetBitmapSize=class(TStatement)
492 exp1,exp2:TPrincipal;
493 constructor create(prev,eld:TStatement);
494 //procedure exec;override;
495 destructor destroy;override;
496 function code:ansistring;override;
497 end;
498
499 constructor TSetBitmapSize.create(prev,eld:TStatement);
500 begin
501 inherited create(prev,eld);
502 exp1 :=NExpression;
503 checktoken(',',IDH_GRAPH_EXT);
504 exp2:=NExpression;
505 end;
506
507 destructor TSetBitmapSize.destroy;
508 begin
509 exp1.free;
510 exp2.free;
511 inherited destroy
512 end;
513
514 (*
515 procedure TSetBitmapSize.exec;
516 begin
517 SetBitMapSize(exp1.evalX,exp2.evalX)
518 end;
519 *)
520
521 type
522 TSetColorMode=class(TStatement)
523 exp1:TPrincipal;
524 constructor create(prev,eld:TStatement);
525 destructor destroy;override;
526 //procedure exec;override;
527 function code:ansistring;override;
528 end;
529
530 constructor TSetColorMode.create(prev,eld:TStatement);
531 begin
532 inherited create(prev,eld);
533 exp1:=SExpression;
534 end;
535
536 destructor TSetColorMode.destroy;
537 begin
538 exp1.free;
539 inherited destroy
540 end;
541
542 (*
543 procedure TSetColorMode.exec;
544 begin
545 MyGraphSys.setcolormode(exp1.evalS);
546 end;
547 *)
548
549 type
550 TSetBeamMode=class(TsetColorMode)
551 //procedure exec;override;
552 function code:ansistring;override;
553 end;
554 (*
555 procedure TSetBeamMode.exec;
556 begin
557 MyGraphSys.setBeamMode(exp1.evalS);
558 end;
559 *)
560
561 function SETst(prev,eld:TStatement):TStatement;
562 begin
563 setst:=nil;
564 if token='WINDOW' then
565 begin
566 gettoken;
567 SETst:=TSetWindow.create(prev,eld);
568 end
569 else if (token='VIEWPORT') then
570 begin
571 gettoken;
572 SETst:=TSetViewport.create(prev,eld);
573 end
574 else if (token='DEVICE') then
575 begin
576 gettoken;
577 if (token='WINDOW') then
578 begin
579 gettoken;
580 SETst:=TSetDeviceWindow.create(prev,eld)
581 end
582 else if(token='VIEWPORT') then
583 begin
584 gettoken;
585 SETst:=TSetDeviceViewport.create(prev,eld)
586 end
587 end
588 else if (token='CLIP') then
589 begin
590 gettoken;
591 SETst:=TSetClip.create(prev,eld);
592 end
593 else if (token='LINE') then
594 begin
595 gettoken;
596 if (token='COLOR') then
597 begin
598 gettoken;
599 SETst:=TSet.createColor(prev,eld,setlinecolor)
600 end
601 else if(token='STYLE') then
602 begin
603 gettoken;
604 SETst:=TSet.create(prev,eld,setlinestyle,maxlinestyle,11062)
605 end
606 else if(token='WIDTH') then
607 begin
608 gettoken;
609 SETst:=TSet.create(prev,eld,setlinewidth,maxint,11062)
610 end
611 end
612 else if (token='POINT') then
613 begin
614 gettoken;
615 if (token='COLOR') then
616 begin
617 gettoken;
618 SETst:=TSet.createColor(prev,eld,setpointcolor)
619 end
620 else if(token='STYLE') then
621 begin
622 gettoken;
623 SETst:=TSet.create(prev,eld,setpointstyle,maxpointstyle,11056)
624 end
625 end
626 else if (token='AREA') then
627 begin
628 gettoken;
629 if (token='COLOR') then
630 begin
631 gettoken;
632 SETst:=TSet.createColor(prev,eld,setareacolor)
633 end
634
635 else if(token='STYLE') then
636 begin
637 gettoken;
638 if token='INDEX' then
639 begin
640 gettoken;
641 SETst:=TSet.create(prev,eld,SetAreaStyleIndex,MaxAreaStyleIndex,11000)
642 end
643 else
644 SETst:=TSetAreaStyle.create(prev,eld)
645 end
646
647 end
648 else if (token='TEXT') then
649 begin
650 gettoken;
651 if (token='COLOR') then
652 begin
653 gettoken;
654 SETst:=TSet.createColor(prev,eld,settextcolor)
655 end
656
657 else if(token='JUSTIFY') then
658 begin
659 gettoken;
660 SETst:=SetTextJustifySt(prev,eld);
661 end
662 else if(token='HEIGHT') then
663 begin
664 gettoken;
665 SETst:=TSetTextHeight.create(prev,eld);
666 end
667 else if(token='ANGLE') then
668 begin
669 gettoken;
670 confirmedDegrees;
671 SETst:=TSetTextAngle.create(prev,eld);
672 end
673 else if(token='FONT') then
674 begin
675 gettoken;
676 SETst:=TSetTextFont.create(prev,eld);
677 end
678
679 else if(token='BACKGROUND') then
680 begin
681 gettoken;
682 SETst:=TSetTextBk.create(prev,eld);
683 end
684
685 end
686 else if (token='COLOR') then
687 begin
688 gettoken;
689 if token='MIX' then
690 begin
691 gettoken;
692 SETst:=TSetColorMix.create(prev,eld)
693 end
694 else if token='MODE' then
695 begin
696 gettoken;
697 SETst:=TSetColorMode.create(prev,eld)
698 end
699 else
700 SETst:=TSet.createColor(prev,eld,setallcolor);
701 end
702 else if (token='DRAW') then
703 begin
704 gettoken;
705 checkToken('MODE',0);
706 SETst:=TSetDrawMode.create(prev,eld);
707 end
708 else if (token='AXIS') then
709 begin
710 gettoken;
711 if (token='COLOR') then
712 begin
713 gettoken;
714 SETst:=TSet.createColor(prev,eld,setaxiscolor)
715 end
716 end
717 else if (token='BITMAP') then
718 begin
719 gettoken;
720 if (token='SIZE') then
721 begin
722 gettoken;
723 SETst:=TSetBitMapSize.create(prev,eld)
724 end
725 end
726 else if (token='BEAM') then
727 begin
728 gettoken;
729 checkToken('MODE',0);
730 SETst:=TSetBeamMode.create(prev,eld);
731 end
732 else
733 SETst:=SetAsk.SETst(prev,eld);
734 end;
735
736
737 {**************}
738 {ASK statements}
739 {**************}
740 (*
741 procedure TAskStatus.StatusInit;
742 begin
743 if status<>nil then
744 status.assignLongint(0)
745 end;
746 *)
747
748 destructor TaskStatus.destroy;
749 begin
750 status.free;
751 inherited destroy;
752 end;
753
754
755 type
756 TAskWindow=class(TaskStatus)
757 exp1,exp2,exp3,exp4:TVariable;
758 constructor create(prev,eld:TStatement);
759 //procedure exec;override;
760 destructor destroy;override;
761 function askCode:ansistring;override;
762 function AskFuncName:ansistring;virtual;
763 end;
764
765
766 constructor TAskWindow.create(prev,eld:TStatement);
767 begin
768 inherited create(prev,eld);
769 exp1:=nvariable;
770 check(',',IDH_WINDOW);
771 exp2:=nvariable;
772 check(',',IDH_WINDOW);
773 exp3:=nvariable;
774 check(',',IDH_WINDOW);
775 exp4:=nvariable;
776
777 if exp1 is TSubstance then
778 TSubstance(exp1).AddQueryInteger(nil); //Integer���������
779 if exp2 is TSubstance then
780 TSubstance(exp2).AddQueryInteger(nil); //Integer���������
781 if exp3 is TSubstance then
782 TSubstance(exp3).AddQueryInteger(nil); //Integer���������
783 if exp4 is TSubstance then
784 TSubstance(exp4).AddQueryInteger(nil); //Integer���������
785
786 end;
787 (*
788 procedure TAskWindow.exec;
789 begin
790 StatusInit;
791 with MyGraphSys do
792 begin
793 exp1.assignX(left);
794 exp2.assignX(right);
795 exp3.assignX(bottom);
796 exp4.assignX(top) ;
797 end;
798 end;
799 *)
800 destructor TAskWindow.destroy;
801 begin
802 exp1.free;
803 exp2.free;
804 exp3.free;
805 exp4.free;
806 inherited destroy;
807 end;
808
809 type
810 TAskViewport=class(TAskWindow)
811 //procedure exec;override;
812 function AskFuncName:ansistring;override;
813 end;
814 (*
815 procedure TAskViewPort.exec;
816 begin
817 StatusInit;
818 with MyGraphSys do
819 begin
820 exp1.assignX(VPleft);
821 exp2.assignX(VPright);
822 exp3.assignX(VPbottom);
823 exp4.assignX(VPtop) ;
824 end;
825 end;
826 *)
827 type
828 TAskDeviceWindow=class(TAskWindow)
829 //procedure exec;override;
830 function AskFuncName:ansistring;override;
831 end;
832 (*
833 procedure TAskDeviceWindow.exec;
834 begin
835 StatusInit;
836 with MyGraphSys do
837 begin
838 exp1.assignX(DWleft);
839 exp2.assignX(DWright);
840 exp3.assignX(DWbottom);
841 exp4.assignX(DWtop) ;
842 end;
843 end;
844 *)
845
846
847 type
848 TAskDeviceViewport=class(TAskWindow)
849 //procedure exec;override;
850 function AskFuncName:ansistring;override;
851 end;
852 (*
853 procedure TAskDeviceViewport.exec;
854 var
855 l,r,b,t:extended;
856 begin
857 StatusInit;
858 MyGraphSys.AskDeviceViewPort(l,r,b,t);
859 exp1.assignX(l);
860 exp2.assignX(r);
861 exp3.assignX(b);
862 exp4.assignX(t);
863 end;
864 *)
865
866 type
867 getfunction=function:integer;
868
869 function getlinecolor:integer;
870 begin
871 getlinecolor:=MyGraphSys.linecolor;
872 end;
873
874 function getlinestyle:integer;
875 begin
876 getlinestyle:=Integer(MyGraphSys.PenStyle) + 1;
877 end;
878
879 function getlinewidth:integer;
880 begin
881 getlinewidth:=MyGraphSys.linewidth;
882 end;
883
884 function getpointcolor:integer;
885 begin
886 getpointcolor:=MyGraphSys.pointcolor;
887 end;
888
889 function getpointstyle:integer;
890 begin
891 getpointstyle:=MyGraphSys.pointstyle;
892 end;
893
894 function getareacolor:integer;
895 begin
896 getareacolor:=MyGraphSys.areacolor;
897 end;
898
899 function gettextcolor:integer;
900 begin
901 gettextcolor:=MyGraphSys.textcolor;
902 end;
903
904 function getmaxcolor:integer;
905 begin
906 if mypalette.PaletteDisabled then
907 result:=$ffffff
908 else
909 result:=GraphSys.maxcolor;
910 end;
911
912 function getaxiscolor:integer;
913 begin
914 getaxiscolor:=GraphSys.axescolor;
915 end;
916
917 function getMaxPointDevice:integer;
918 begin
919 result:=1
920 end;
921
922 function getMaxMultiPointDevice:integer;
923 begin
924 result:=1
925 end;
926
927 function getMaxChoiceDevice:integer;
928 begin
929 result:=8
930 end;
931
932 function getMaxValueDevice:integer;
933 begin
934 result:=1
935 end;
936
937 function getAreaStyleIndex:integer;
938 begin
939 result:=MyGraphSys.AreaStyleIndex;
940 end;
941
942
943
944
945 function getmaxlinestyle:integer;
946 begin
947 getmaxlinestyle:=MaxLineStyle
948 end;
949
950 function getmaxpointstyle:integer;
951 begin
952 getmaxpointstyle:=MaxPointStyle
953 end;
954
955 type
956 TAsk=class(TaskStatus)
957 exp:TVariable;
958 get:getfunction;
959 constructor create(prev,eld:TStatement; g:getfunction);
960 //procedure exec;override;
961 destructor destroy;override;
962 function AskCode:ansistring;override;
963 function AskFuncName:ansistring;virtual;
964 end;
965
966 constructor TAsk.create(prev,eld:TStatement; g:getfunction);
967 begin
968 inherited create(prev,eld);
969 exp:=nvariable;
970 get:=g;
971 if exp is TSubstance then
972 TSubstance(exp).AddQueryInteger(nil); //Integer���������
973
974 end;
975 (*
976 procedure TAsk.exec;
977 begin
978 StatusInit;
979 exp.assignLongint(get)
980 end;
981 *)
982 destructor TAsk.destroy;
983 begin
984 exp.free;
985 inherited destroy;
986 end;
987
988
989 type
990 TAskTextHeight=class(TAsk)
991 //procedure exec;override;
992 function AskFuncName:ansistring;override;
993 end;
994 (*
995 procedure TAskTextHeight.exec;
996 begin
997 StatusInit;
998 exp.assignX(MyGraphSys.gettextheight);
999 end;
1000 *)
1001 type
1002 TAskTextAngle=class(TAsk)
1003 //procedure exec;override;
1004 function AskFuncName:ansistring;override;
1005 end;
1006 (*
1007 procedure TAskTextAngle.exec;
1008 var
1009 x:extended;
1010 begin
1011 StatusInit;
1012 x:=MyGraphSys.TextAngle;
1013 if not Punit.AngleDegrees then x:=x/180.0*PI;
1014 exp.assignX(x);
1015 end;
1016 *)
1017
1018 type
1019 TAskPixelSize=class(TaskStatus)
1020 exp1,exp2,exp3,exp4:TPrincipal;
1021 var1,var2:TVariable;
1022 constructor create(prev,eld:TStatement);
1023 //procedure exec;override;
1024 destructor destroy;override;
1025 function AskCode:ansistring;override;
1026 end;
1027
1028 constructor TAskPixelSize.create(prev,eld:TStatement);
1029 begin
1030 inherited create(prev,eld);
1031 if token='(' then
1032 begin
1033 check('(',IDH_PIXEL_SIZE);
1034 exp1:=NExpression;
1035 check(',',IDH_PIXEL_SIZE);
1036 exp2:=NExpression;
1037 check(';',IDH_PIXEL_SIZE);
1038 exp3:=NExpression;
1039 check(',',IDH_PIXEL_SIZE);
1040 exp4:=NExpression;
1041 check(')',IDH_PIXEL_SIZE);
1042 end;
1043 var1:=NVariable;
1044 check(',',IDH_PIXEL_SIZE);
1045 var2:=NVariable;
1046
1047 //var1,var2������������integer���or double���������.
1048 if var1 is TSubstance then
1049 TSubstance(var1).AddQueryInteger(var2.queryInteger);
1050 if var2 is TSubstance then
1051 TSubstance(var2).AddQueryInteger(var1.queryInteger);
1052 end;
1053
1054 destructor TAskPixelSize.destroy;
1055 begin
1056 exp1.free;
1057 exp2.free;
1058 exp3.free;
1059 exp4.free;
1060 var1.free;
1061 var2.free;
1062 inherited destroy;
1063 end;
1064 (*
1065 procedure TAskPixelSize.exec;
1066 function Floor(x:extended):extended; assembler;
1067 asm
1068 FLD x
1069 FLDCW RoundNins
1070 FRNDINT
1071 FLDCW RoundMost
1072 end;
1073 function Ceil(x:extended):extended; assembler;
1074 asm
1075 FLD x
1076 FLDCW RoundPlus
1077 FRNDINT
1078 FLDCW RoundMost
1079 end;
1080 const eps=1e-15;
1081 var
1082 n1,n2,n3,n4,t:extended;
1083 x1,x2,y1,y2:extended;
1084 begin
1085 StatusInit;
1086 if exp1=nil then
1087 begin
1088 var1.assignX(MyGraphSys.GWidth);
1089 var2.assignX(MyGraphSys.GHeight)
1090 end
1091 else
1092 begin
1093 n1:=exp1.evalX;
1094 n2:=exp2.evalX;
1095 n3:=exp3.evalX;
1096 n4:=exp4.evalX;
1097 if n1>n3 then begin t:=n3; n3:=n1; n1:=t end;
1098 if n2<n4 then begin t:=n4; n4:=n2; n2:=t end;
1099
1100
1101 x1:=ceil(MyGraphSys.DeviceX(n1)-eps);
1102 x2:=floor(MyGraphSys.DeviceX(n3)+eps);
1103 y1:=ceil(MyGraphSys.DeviceY(n2)-eps);
1104 y2:=floor(MyGraphSys.DeviceY(n4)+eps);
1105 var1.assignX(x2-x1+1);
1106 var2.assignX(y2-y1+1)
1107 end
1108 ;
1109 end;
1110 *)
1111
1112 type
1113 TAskPixelValue=class(TaskStatus)
1114 exp1,exp2:TPrincipal;
1115 var1:TVariable;
1116 constructor create(prev,eld:TStatement);
1117 //procedure exec;override;
1118 destructor destroy;override;
1119 function ASkCode:ansistring;override;
1120 end;
1121
1122 constructor TAskPixelValue.create(prev,eld:TStatement);
1123 begin
1124 inherited create(prev,eld);
1125 check('(',IDH_PIXEL);
1126 exp1:=NExpression;
1127 check(',',IDH_PIXEL);
1128 exp2:=NExpression;
1129 check(')',IDH_PIXEL);
1130 var1:=NVariable;
1131 if var1 is TSubstance then
1132 TSubstance(var1).AddQueryInteger(nil); //Integer���������
1133
1134 end;
1135
1136 destructor TAskPixelValue.destroy;
1137 begin
1138 exp1.free;
1139 exp2.free;
1140 var1.free;
1141 inherited destroy;
1142 end;
1143 (*
1144 procedure TAskPixelValue.exec;
1145 begin
1146 StatusInit;
1147 var1.assignLongint(MyGraphSys.ColorIndexOf(MyGraphSys.DeviceX(exp1.evalX),
1148 MyGraphSys.DeviceY(exp2.evalX)))
1149 end;
1150 *)
1151 type
1152 TAskDeviceSize=class(TaskStatus)
1153 exp1,exp2:TVariable;
1154 exp3:TStrVari;
1155 constructor create(prev,eld:TStatement);
1156 //procedure exec;override;
1157 destructor destroy;override;
1158 function AskCode:ansistring;override;
1159 end;
1160
1161
1162 constructor TAskDeviceSize.create(prev,eld:TStatement);
1163 begin
1164 inherited create(prev,eld);
1165 exp1:=nvariable;
1166 check(',',IDH_GRAPHICS);
1167 exp2:=nvariable;
1168 check(',',IDH_GRAPHICS);
1169 exp3:=Strvari;
1170
1171 if exp1 is TSubstance then
1172 TSubstance(exp1).AddQueryInteger(nil); //Integer���������
1173 if exp2 is TSubstance then
1174 TSubstance(exp2).AddQueryInteger(nil); //Integer���������
1175
1176 end;
1177 (*
1178 procedure TAskDeviceSize.exec;
1179 var
1180 w,h:extended;
1181 s:string;
1182 begin
1183 StatusInit;
1184 MyGraphSys.AskDeviceSize(w,h,s);
1185 exp1.assignX(w);
1186 exp2.assignX(h);
1187 exp3.substS(s) ;
1188 end;
1189 *)
1190 destructor TAskDeviceSize.destroy;
1191 begin
1192 exp1.free;
1193 exp2.free;
1194 exp3.free;
1195 inherited destroy;
1196 end;
1197
1198 type
1199 TAskBitmapSize=class(TaskStatus)
1200 exp1,exp2:TVariable;
1201 constructor create(prev,eld:TStatement);
1202 //procedure exec;override;
1203 destructor destroy;override;
1204 function AskCode:AnsiString;override;
1205 end;
1206
1207
1208 constructor TAskBitmapSize.create(prev,eld:TStatement);
1209 begin
1210 inherited create(prev,eld);
1211 exp1:=nvariable;
1212 check(',',IDH_GRAPHICS);
1213 exp2:=nvariable;
1214
1215 if exp1 is TSubstance then
1216 TSubstance(exp1).AddQueryInteger(nil); //Integer���������
1217 if exp2 is TSubstance then
1218 TSubstance(exp2).AddQueryInteger(nil); //Integer���������
1219
1220 end;
1221 (*
1222 procedure TAskBitmapSize.exec;
1223 begin
1224 StatusInit;
1225 exp1.assignX(MyGraphSys.GWidth);
1226 exp2.assignX(MyGraphSys.GHeight)
1227 end;
1228 *)
1229 destructor TAskBitmapSize.destroy;
1230 begin
1231 exp1.free;
1232 exp2.free;
1233 inherited destroy;
1234 end;
1235
1236
1237 type
1238 TAskPixelArray=class(TaskStatus)
1239 exp1,exp2:TPrincipal;
1240 mat1:TMatrix;
1241 exp3:TStrVari;
1242 constructor create(prev,eld:TStatement);
1243 //procedure exec;override;
1244 destructor destroy;override;
1245 function ASkCode:ansistring;override;
1246 end;
1247
1248 constructor TAskPixelArray.create(prev,eld:TStatement);
1249 begin
1250 inherited create(prev,eld);
1251 check('(',IDH_PIXEL);
1252 exp1:=NExpression;
1253 check(',',IDH_PIXEL);
1254 exp2:=NExpression;
1255 check(')',IDH_PIXEL);
1256 mat1:=NMatrix;
1257 if mat1.idr.dim<>2 then seterrDimension(IDH_PIXEL);
1258 if test(',') then
1259 exp3:=StrVari;
1260 end;
1261
1262 destructor TAskPixelArray.destroy;
1263 begin
1264 exp1.free;
1265 exp2.free;
1266 mat1.free;
1267 exp3.free;
1268 inherited destroy;
1269 end;
1270 (*
1271 procedure TAskPixelArray.exec;
1272 var
1273 x1,y1:longint;
1274 i,j:longint;
1275 p:TArray;
1276 c:integer;
1277 text:ansistring;
1278 begin
1279 StatusInit;
1280 x1:=MyGraphSys.DeviceX(exp1.evalX);
1281 y1:=MyGraphSys.DeviceY(exp2.evalX);
1282 TVar(p):=mat1.point;
1283 text:='PRESENT';
1284 if p<>nil then
1285 begin
1286 for i:=0 to p.size[1]-1 do
1287 for j:=0 to p.size[2]-1 do
1288 begin
1289 c:=MyGraphSys.ColorIndexOf(x1+i,y1+j);
1290 with p do ItemAssignLongint(i*size[2]+j,c);
1291 if c=-1 then text:='ABSENT';
1292 end;
1293 if exp3<>nil then
1294 exp3.substS(text);
1295 end
1296 end;
1297 *)
1298
1299 type
1300 TAskTextJustify=class(TaskStatus)
1301 exp1,exp2:TStrVari;
1302 constructor create(prev,eld:TStatement);
1303 //procedure exec;override;
1304 destructor destroy;override;
1305 function AskCode:Ansistring;override;
1306 end;
1307
1308
1309 constructor TAskTextJustify.create(prev,eld:TStatement);
1310 begin
1311 inherited create(prev,eld);
1312 exp1:=StrVari;
1313 check(',',IDH_TEXT);
1314 exp2:=StrVari;
1315 end;
1316 (*
1317 procedure TAskTextJustify.exec;
1318 begin
1319 StatusInit;
1320 with MyGraphSys do
1321 begin
1322 exp1.substS(HJustification[HJustify]);
1323 exp2.substS(VJustification[VJustify])
1324 end;
1325 end;
1326 *)
1327 destructor TAskTextJustify.destroy;
1328 begin
1329 exp1.free;
1330 exp2.free;
1331 inherited destroy;
1332 end;
1333
1334 type
1335 TAskTextWidth=class(TaskStatus)
1336 Text:TPrincipal;
1337 Width:TVariable;
1338 constructor create(prev,eld:TStatement);
1339 destructor destroy;override;
1340 //procedure exec;override;
1341 function AskCode:AnsiString;override;
1342 end;
1343
1344 constructor TAskTextWidth.create(prev,eld:TStatement);
1345 begin
1346 inherited create(prev,eld);
1347 Check('(',IDH_COLOR);
1348 Text:=SExpression;
1349 check(')',IDH_COLOR);
1350 Width:=NVariable;
1351 if Width is TSubstance then
1352 TSubstance(Width).AddQueryInteger(nil); //Integer���������
1353
1354 end;
1355
1356 destructor TAskTextWidth.destroy;
1357 begin
1358 Text.free;
1359 Width.free;
1360 inherited destroy
1361 end;
1362 (*
1363 procedure TAskTextWidth.exec;
1364 var
1365 s:string;
1366 w:integer;
1367 x:extended;
1368 begin
1369 StatusInit;
1370 with MyGraphSys do
1371 Width.assignX(VirtualX(textwidth(Text.evalS))-VirtualX(0));
1372 end;
1373 *)
1374
1375
1376 type
1377 TAskColorMix=class(TaskStatus)
1378 ColorIndex:TPrincipal;
1379 Red,Green,Blue:TVariable;
1380 constructor create(prev,eld:TStatement);
1381 destructor destroy;override;
1382 //procedure exec;override;
1383 function AskCode:ansistring;override;
1384 end;
1385
1386 constructor TAskColorMix.create(prev,eld:TStatement);
1387 begin
1388 inherited create(prev,eld);
1389 Check('(',IDH_COLOR);
1390 ColorIndex:=nexpression;
1391 check(')',IDH_COLOR);
1392 Red:=NVariable;
1393 check(',',IDH_COLOR);
1394 Green:=NVariable;
1395 check(',',IDH_COLOR);
1396 Blue:=NVariable;
1397
1398 if Red is TSubstance then
1399 TSubstance(Red).AddQueryInteger(nil); //Integer���������
1400 if Green is TSubstance then
1401 TSubstance(Green).AddQueryInteger(nil); //Integer���������
1402 if Blue is TSubstance then
1403 TSubstance(Blue).AddQueryInteger(nil); //Integer���������
1404
1405 end;
1406
1407 destructor TAskColorMix.destroy;
1408 begin
1409 ColorIndex.free;
1410 Red.free;
1411 Green.free;
1412 Blue.free;
1413 inherited destroy
1414 end;
1415
1416 procedure AskColorMix(cc:integer;var r,g,b:byte);
1417 var
1418 col:TColor;
1419 begin
1420 col:=MyPalette[cc];
1421 b:=(col and $ff0000) div $10000;
1422 g:=(col and $00ff00) div $100;
1423 r:=col and $0000ff;
1424 end;
1425 (*
1426 procedure TAskColorMix.exec;
1427 var
1428 cc:longint;
1429 r,g,b:byte;
1430 begin
1431 StatusInit;
1432 cc:=ColorIndex.evalLongint;
1433 if (cc<0) or (cc>maxcolor) and not MyPalette.paletteDisabled then
1434 begin
1435 red.assignLongInt(0);
1436 green.assignLongint(0);
1437 blue.assignLongint(0);
1438 if status<>nil then
1439 status.assignLongint(11086);
1440 end
1441 else
1442 begin
1443 askColorMix(cc,r,g,b);
1444 red.assignX(r/255);
1445 green.assignX(g/255);
1446 blue.assignX(b/255);
1447 end;
1448 end;
1449 *)
1450 type
1451 TAskClip=class(TaskStatus)
1452 exp:TStrVari;
1453 constructor create(prev,eld:TStatement);
1454 //procedure exec;override;
1455 destructor destroy;override;
1456 function AskCode:ansistring;override;
1457 function AskFuncName:ansistring;virtual;
1458 end;
1459
1460
1461 constructor TAskClip.create(prev,eld:TStatement);
1462 begin
1463 inherited create(prev,eld);
1464 exp:=StrVari;
1465 end;
1466 (*
1467 procedure TAskClip.exec;
1468 var
1469 s:string;
1470 begin
1471 StatusInit;
1472 if MyGraphSys.clip then s:='ON' else s:='OFF';
1473 exp.substS(s);
1474 end;
1475 *)
1476 destructor TAskClip.destroy;
1477 begin
1478 exp.free;
1479 inherited destroy;
1480 end;
1481
1482 type
1483 TAskAreaStyle=class(TAskClip)
1484 // procedure exec;override;
1485 function AskFuncName:ansistring;override;
1486 end;
1487 (*
1488 procedure TAskAreaStyle.exec;
1489 var
1490 s:string;
1491 begin
1492 StatusInit;
1493 case MyGraphSys.AreaStyle of
1494 asSolid: s:='SOLID';
1495 asHollow:s:='HOLLOW';
1496 asHATCH: s:='HATCH';
1497 end;
1498 exp.substS(s);
1499 end;
1500 *)
1501
1502 type
1503 TAskColorMode=class(TAskClip)
1504 //procedure exec;override;
1505 function AskFuncName:ansistring;override;
1506 end;
1507 (*
1508 procedure TAskColorMode.exec;
1509 var
1510 s:string;
1511 begin
1512 StatusInit;
1513 exp.substS(MyGraphSys.AskColorMode);
1514 end;
1515 *)
1516 type
1517 TAskBeamMode=class(TAskClip)
1518 //procedure exec;override;
1519 function AskFuncName:ansistring;override;
1520 end;
1521 (*
1522 procedure TAskBeamMode.exec;
1523 var
1524 s:string;
1525 begin
1526 StatusInit;
1527 exp.substS(MyGraphSys.AskBeamMode);
1528 end;
1529 *)
1530
1531
1532 function ASKst(prev,eld:TStatement):TAskStatus;
1533 begin
1534 ASKst:=nil;
1535 if token='WINDOW' then
1536 begin
1537 gettoken;
1538 ASKst:=TAskWindow.create(prev,eld);
1539 end
1540 else if token='VIEWPORT' then
1541 begin
1542 gettoken;
1543 ASKst:=TAskViewport.create(prev,eld);
1544 end
1545 else if (token='LINE') then
1546 begin
1547 gettoken;
1548 if (token='COLOR') then
1549 begin
1550 gettoken;
1551 ASKst:=TAsk.create(prev,eld,getlinecolor)
1552 end
1553 else if(token='STYLE') then
1554 begin
1555 gettoken;
1556 ASKst:=TAsk.create(prev,eld,getlinestyle)
1557 end
1558 else if(token='WIDTH') then
1559 begin
1560 gettoken;
1561 ASKst:=TAsk.create(prev,eld,getlinewidth)
1562 end
1563 end
1564 else if (token='POINT') then
1565 begin
1566 gettoken;
1567 if (token='COLOR') then
1568 begin
1569 gettoken;
1570 askst:=TAsk.create(prev,eld,getpointcolor)
1571 end
1572 else if(token='STYLE') then
1573 begin
1574 gettoken;
1575 ASKst:=TAsk.create(prev,eld,getpointstyle)
1576 end
1577 end
1578 else if (token='AREA') then
1579 begin
1580 gettoken;
1581 if (token='COLOR') then
1582 begin
1583 gettoken;
1584 ASKst:=TAsk.create(prev,eld,getareacolor)
1585 end
1586 else if(token='STYLE') then
1587 begin
1588 gettoken;
1589 if token='INDEX' then
1590 begin
1591 gettoken;
1592 ASKst:=TAsk.create(prev,eld,getAreaStyleIndex);
1593 end
1594 else
1595 ASKst:=TAskAreaStyle.create(prev,eld)
1596 end
1597 end
1598 else if (token='TEXT') then
1599 begin
1600 gettoken;
1601 if (token='COLOR') then
1602 begin
1603 gettoken;
1604 ASKst:=TASK.create(prev,eld,gettextcolor)
1605 end
1606 else if (token='HEIGHT') then
1607 begin
1608 gettoken;
1609 ASKst:=TASKTextHeight.create(prev,eld,nil)
1610 end
1611 else if (token='ANGLE') then
1612 begin
1613 gettoken;
1614 confirmedDegrees;
1615 ASKst:=TASKTextAngle.create(prev,eld,nil);
1616 end
1617 else if(token='JUSTIFY') then
1618 begin
1619 gettoken;
1620 ASKst:=TAskTextJustify.create(prev,eld)
1621 end
1622 else if(token='WIDTH') then
1623 begin
1624 gettoken;
1625 ASKst:=TAskTextWidth.create(prev,eld)
1626 end
1627 end
1628 else if token='MAX' then
1629 begin
1630 gettoken;
1631 if token='POINT' then
1632 begin
1633 gettoken;
1634 if token='STYLE' then
1635 begin
1636 gettoken;
1637 ASKst:=TAsk.create(prev,eld,getmaxpointstyle);
1638 end
1639 else if token='DEVICE' then
1640 begin
1641 gettoken;
1642 ASKst:=TAsk.create(prev,eld,getmaxpointdevice);
1643 end
1644 end
1645 else if token='LINE' then
1646 begin
1647 gettoken;
1648 checktoken('STYLE',IDH_LINE);
1649 ASKst:=TAsk.create(prev,eld,getmaxlinestyle);
1650 end
1651 else if token='COLOR' then
1652 begin
1653 gettoken;
1654 ASKst:=TAsk.create(prev,eld,getmaxcolor);
1655 end
1656 else if token='MULTIPOINT' then
1657 begin
1658 gettoken;
1659 CheckToken('DEVICE',IDH_LOCATE);
1660 ASKst:=TAsk.create(prev,eld,getmaxMultipointdevice);
1661 end
1662 else if token='CHOICE' then
1663 begin
1664 gettoken;
1665 CheckToken('DEVICE',IDH_LOCATE);
1666 ASKst:=TAsk.create(prev,eld,getmaxChoiceDevice);
1667 end
1668 else if token='VALUE' then
1669 begin
1670 gettoken;
1671 CheckToken('DEVICE',IDH_LOCATE);
1672 ASKst:=TAsk.create(prev,eld,getmaxValueDevice);
1673 end
1674 end
1675 else if token='PIXEL' then
1676 begin
1677 gettoken;
1678 if token='SIZE' then
1679 begin
1680 gettoken;
1681 ASKst:=TAskPixelSize.create(prev,eld);
1682 end
1683 else if token='VALUE' then
1684 begin
1685 gettoken;
1686 ASKst:=TAskPixelValue.create(prev,eld);
1687 end
1688 else if token='ARRAY' then
1689 begin
1690 gettoken;
1691 ASKst:=TAskPixelArray.create(prev,eld);
1692 end;
1693 end
1694 else if token='DEVICE' then
1695 begin
1696 gettoken;
1697 if token='VIEWPORT' then
1698 begin
1699 gettoken;
1700 ASKst:=TAskDeviceViewport.create(prev,eld);
1701 end
1702 else if token='WINDOW' then
1703 begin
1704 gettoken;
1705 ASKst:=TAskDeviceWindow.create(prev,eld);
1706 end
1707 else if token='SIZE' then
1708 begin
1709 gettoken;
1710 ASKst:=TAskDeviceSize.create(prev,eld);
1711 end
1712 end
1713 else if token='CLIP' then
1714 begin
1715 gettoken;
1716 ASKst:=TAskClip.create(prev,eld);
1717 end
1718 else if (token='AXIS') then
1719 begin
1720 gettoken;
1721 if (token='COLOR') then
1722 begin
1723 gettoken;
1724 askst:=TAsk.create(prev,eld,getaxiscolor)
1725 end
1726 end
1727 else if token='COLOR' then
1728 begin
1729 gettoken;
1730 if token='MIX' then
1731 begin
1732 gettoken;
1733 ASKst:=TAskColorMix.create(prev,eld);
1734 end
1735 else if token='MODE' then
1736 begin
1737 gettoken;
1738 ASKst:=TAskColorMode.create(prev,eld);
1739 end
1740 end
1741 else if token='PIXELS' then
1742 begin
1743 gettoken;
1744 ASKst:=TAskBitMapSize.create(prev,eld);
1745 end
1746 else if token='BITMAP' then
1747 begin
1748 gettoken;
1749 if token='SIZE' then
1750 begin
1751 gettoken;
1752 ASKst:=TAskBitMapSize.create(prev,eld);
1753 end
1754 end
1755 else if token='BEAM' then
1756 begin
1757 gettoken;
1758 if token='MODE' then
1759 begin
1760 gettoken;
1761 ASKst:=TAskBeamMode.create(prev,eld);
1762 end
1763 end
1764 else
1765 seterrIllegal(token,0);
1766
1767 if token='STATUS' then
1768 begin
1769 gettoken;
1770 result.status:=nVariable;
1771 if result.status is TSubstance then
1772 TSubstance(result.status).AddQueryInteger(nil); //Integer���������
1773
1774 end;
1775 end;
1776
1777 (*
1778 function newpairlist(n:integer):PPointpairlist;
1779 begin
1780 GetMem(pointer(result),sizeof(integer)+sizeof(pointpair)*n);
1781 result^.count:=n
1782 end;
1783
1784
1785 procedure disposepairlist(p:PPointpairlist);
1786 begin
1787 if p<>nil then FreeMem(pointer(p),sizeof(integer)+sizeof(pointpair)*p^.count)
1788 end;
1789 *)
1790
1791 {*************}
1792 {PLOT or GRAPH}
1793 {*************}
1794
1795
1796
1797 type
1798 TPlotItem=class
1799 exp1,exp2:TPrincipal;
1800 next:TPlotItem;
1801 PLOTstm:boolean;
1802 constructor create(plot:boolean; prev:TPlotItem); //2011.3.5
1803 procedure PutMark;
1804 procedure PlotTo;
1805 function eval(var x,y:extended):boolean;
1806 destructor Destroy;override;
1807 function ItemCode:Ansistring;
1808 end;
1809
1810 (*
1811 constructor TPlotItem.create(plot:boolean);
1812 begin
1813 inherited create;
1814 PLOTstm:=plot;
1815 exp1:=NExpression;
1816 check(',',IDH_GRAPHICS);
1817 exp2:=NExpression;
1818 if (token=';') and (nextTokenSpec<>tail) and (NextToken<>'ELSE') then
1819 begin
1820 gettoken;
1821 next:=TPlotItem.create(PLOTstm);
1822 end;
1823 end;
1824 *)
1825
1826 constructor TPlotItem.create(plot:boolean; prev:TPlotItem); //2011.3.5
1827 begin
1828 inherited create;
1829 PLOTstm:=plot;
1830 exp1:=NExpression;
1831 if (programunit.Arithmetic<>PrecisionComplex)
1832 or (prev=nil) and (token=',')
1833 or (prev<>nil) and (prev.exp2<>nil) then
1834 begin
1835 check(',',IDH_GRAPHICS);
1836 exp2:=NExpression;
1837 end;
1838 if (token=';') and (nextTokenSpec<>tail) and (NextToken<>'ELSE') then
1839 begin
1840 gettoken;
1841 next:=TPlotItem.create(PLOTstm, self);
1842 end;
1843 end;
1844
1845 destructor TPlotItem.Destroy;
1846 begin
1847 next.free;
1848 exp2.free;
1849 exp1.free;
1850 inherited destroy;
1851 end;
1852
1853 procedure TPlotItem.PutMark;
1854 var
1855 x,y:extended;
1856 begin
1857 if self=nil then exit;
1858 x:=exp1.evalX;
1859 y:=exp2.evalX;
1860 if PLOTstm then
1861 GraphLib.PlotPoints([x,y])
1862 else
1863 // GraphLib.GraphPoint(x,y);
1864 next.PutMark
1865 end;
1866
1867 procedure TPlotItem.PlotTo;
1868 var
1869 x,y:extended;
1870 begin
1871 if self=nil then exit;
1872 x:=exp1.evalX;
1873 y:=exp2.evalX;
1874 if PLOTstm then
1875 GraphLib.PlotLines([x,y])
1876 else
1877 //GraphLib.GPlotTo(x,y);
1878 next.PlotTo
1879 end;
1880
1881 function TPlotItem.eval(var x,y:extended):boolean;
1882 begin
1883 {
1884 x:=exp1.evalX;
1885 y:=exp2.evalX;
1886 result:=not PLOTstm or currenttransform.transform(x,y);
1887 }
1888 end;
1889
1890 type
1891 TPlotPoints=class(TStatement)
1892 Items:TPlotItem;
1893 GRAPHst:Boolean;
1894 cont:Boolean;
1895 constructor create(prev,eld:TStatement; plot:boolean);
1896 constructor createnul(prev,eld:TStatement); //PLOT LINES������������
1897 //procedure exec;override;
1898 destructor destroy;override;
1899 function Code:AnsiString;override;
1900 end;
1901
1902 TPlotLines=class(TPlotPoints)
1903 constructor create(prev,eld:TStatement; plot:boolean);
1904 //procedure exec;override;
1905 function Code:AnsiString;override;
1906 end;
1907
1908 constructor TPlotPoints.create(prev,eld:TStatement; plot:boolean);
1909 begin
1910 inherited create(prev,eld);
1911 Items:=TPlotItem.create(plot, nil);
1912 end;
1913
1914 constructor TPlotLines.create(prev,eld:TStatement; plot:boolean);
1915 begin
1916 inherited create(prev,eld,plot);
1917 if not plot then GRAPHst:=true;
1918 if plot and (token=';') then
1919 begin
1920 cont:=true;
1921 gettoken;
1922 end;
1923 end;
1924
1925 constructor TPlotPoints.createnul(prev,eld:TStatement);
1926 begin
1927 inherited Create(prev,eld);
1928 GRAPHst:=false;
1929 cont:=false;
1930 end;
1931
1932
1933 destructor TPlotPoints.destroy;
1934 begin
1935 Items.free;
1936 inherited destroy
1937 end;
1938 (*
1939 procedure TPlotPoints.exec;
1940 begin
1941 with MyGraphSys do
1942 if BeamMode=bmRigorous then beam:=false;
1943 Items.PutMark;
1944 end;
1945
1946 procedure TPlotLines.exec;
1947 begin
1948 if GRAPHst then MyGraphSys.beam:=false;
1949 Items.PlotTo;
1950 if not cont then
1951 MyGraphSys.beam:=false;
1952 end;
1953 *)
1954
1955 type
1956 TPointArray=array[ 0..1023] of TPoint;
1957 PPointArray=^TPointArray;
1958
1959 type
1960 TCoordinate=Packed Record
1961 x,y:extended;
1962 end;
1963 TCoordinateArray=Packed Array[0..1023] of TCoordinate;
1964 PCoordinateArray=^TCoordinateArray;
1965
1966
1967 function NormalSegment(const x0,y0,x1,y1:extended):boolean;
1968 var
1969 a,b,s,t:extended;
1970 begin
1971 result:=true;
1972 if CurrentTransform=nil then exit;
1973 with CurrentTransform do
1974 begin
1975 a:=x1-x0;
1976 b:=y1-y0;
1977 s:=ox*a+oy*b;
1978 t:=-(ox*x0+oy*y0+oo);
1979 if s<>0 then
1980 begin
1981 t:=t/s;
1982 if (t>=0) and (t<=1) then
1983 result:=false;
1984 end
1985 else if t=0 then
1986 result:=false;
1987 end
1988 end;
1989
1990
1991 function TestNormalSegments(p:PCoordinateArray; count:integer):boolean;
1992 var
1993 i:integer;
1994 begin
1995 result:=true;
1996 for i:=0 to count-1 do
1997 result:=result and NormalSegment(p^[i].x, p^[i].y,
1998 p^[(i+1)mod count].x, p^[(i+1)mod count].y);
1999 end;
2000
2001 type
2002 TPlotOrg=class(TStatement)
2003 pointpairs:TObjectList;
2004 limit:TPrincipal;
2005 mat,mat2:TMatrix;
2006 GRAPHst :boolean;
2007 constructor create(prev,eld:TStatement; plot:boolean);
2008 constructor createmat(prev,eld:TStatement; plot:boolean);
2009 destructor destroy;override;
2010 //function evalLimit:integer;
2011 //function MakeList(p:PPointArray; lim:integer):integer; //���������������������
2012 //procedure MakeCoordinateList(p:PCoordinateArray; lim:integer); //������������������
2013 //function ReMakeList(p:PCoordinateArray; q:PPointArray; count:integer):integer; //���������������������
2014 //procedure PlotProjectiveLine(lim:integer);
2015 {Code Gen}
2016 function PointCode:Ansistring;
2017 end;
2018
2019 TMatPlotPoints=class(TPlotOrg)
2020 //procedure exec;override;
2021 function Code:Ansistring;override;
2022 end;
2023
2024 TMatPlotLines=class(TPlotOrg)
2025 cont:boolean;
2026 constructor create(prev,eld:TStatement; plot:boolean);
2027 //constructor createnul(prev,eld:TStatement);
2028 //procedure exec;override;
2029 function Code:Ansistring;override;
2030 end;
2031
2032 TPlotArea=class(TPlotOrg)
2033 constructor create(prev,eld:TStatement; plot:boolean);
2034 //procedure exec;override;
2035 //procedure ProjectivePolygon(lim:integer);
2036 function Code:Ansistring;override;
2037 end;
2038
2039 TPlotBezier=class(TStatement)
2040 expx: array[0..3]of TPrincipal;
2041 expy: array[0..3]of TPrincipal;
2042 GRAPHst :boolean;
2043 constructor create(prev,eld:TStatement; plot:boolean);
2044 //procedure exec;override;
2045 destructor destroy;override;
2046 end;
2047
2048
2049 function PLOTst(prev,eld:TStatement):TStatement;
2050 var
2051 plot:boolean;
2052 begin
2053 PLOTst:=nil;
2054 GraphMode:=true;
2055 plot:=(prevToken='PLOT');
2056 if token='POINTS' then
2057 begin
2058 gettoken;
2059 checktoken(':',IDH_GRAPHICS);
2060 PLOTst:=TPlotPoints.create(prev,eld,plot)
2061 end
2062 else if (token='LINES') then
2063 begin
2064 gettoken;
2065 if ( ((tokenspec=tail) or (token='ELSE'))
2066 or ((token=':') and (nexttoken='') ))
2067 and plot then
2068 PLOTst:=TPlotLines.createnul(prev,eld)
2069 else
2070 begin
2071 checktoken(':',IDH_LINE);
2072 PLOTst:=TPlotLines.create(prev,eld,plot)
2073 end
2074 end
2075 else if token='AREA' then
2076 begin
2077 gettoken;
2078 checktoken(':',IDH_AREA);
2079 PLOTst:=TPLotArea.create(prev,eld,plot)
2080 end
2081 else if (token='TEXT') or (token='LABEL') or plot and (token='LETTERS') then
2082 begin
2083 PLOTst:=PlotTextst(prev,eld)
2084 end
2085 else if token='BEZIER' then
2086 begin
2087 gettoken;
2088 checktoken(':',IDH_AREA);
2089 PLOTst:=TPLotBezier.create(prev,eld,plot)
2090 end
2091 else if ((tokenspec=tail) or (token='ELSE')) and plot then
2092 PLOTst:=TPlotLines.createnul(prev,eld)
2093 else if plot then
2094 PLOTst:=TPlotLines.create(prev,eld,plot);
2095 end;
2096
2097 (*
2098 constructor TPlotOrg.create(prev,eld:TStatement; plot:boolean);
2099 var
2100 exp:TPrincipal;
2101 Label
2102 L1;
2103 begin
2104 inherited create(prev,eld);
2105 GRAPHst:=not plot;
2106 pointpairs:=TObjectList.create(4);
2107 repeat
2108 exp:=nexpression;
2109 pointpairs.add(exp);
2110 check(',',IDH_GRAPHICS);
2111 exp:=nexpression;
2112 pointpairs.add(exp);
2113 if (token=';') and (nexttokenspec<>tail) and (nexttoken<>'ELSE') then
2114 gettoken
2115 else
2116 goto L1;
2117 until false;
2118 L1:
2119 end;
2120 *)
2121 constructor TPlotOrg.create(prev,eld:TStatement; plot:boolean); //2011.3.5
2122 var
2123 exp:TPrincipal;
2124 flag:boolean;
2125 Label
2126 L1;
2127 begin
2128 inherited create(prev,eld);
2129 flag:=false;
2130 GRAPHst:=not plot;
2131 pointpairs:=TObjectList.create(4);
2132 repeat
2133 exp:=nexpression;
2134 pointpairs.add(exp);
2135 if ((programunit.Arithmetic<>PrecisionComplex) or (token=',')) and not flag then
2136 begin
2137 check(',',IDH_GRAPHICS);
2138 exp:=nexpression;
2139 end
2140 else
2141 begin
2142 exp:=nil;
2143 flag:=true;
2144 end;
2145 pointpairs.add(exp);
2146 if (token=';') and (nexttokenspec<>tail) and (nexttoken<>'ELSE') then
2147 gettoken
2148 else
2149 goto L1;
2150 until false;
2151 L1:
2152 end;
2153
2154 (*
2155 constructor TPlotOrg.createmat(prev,eld:TStatement; plot:boolean);
2156 begin
2157 graphmode:=true;
2158 inherited create(prev,eld);
2159 GRAPHst:=not plot;
2160 gettoken; {POINTS, etc.}
2161 if test(',') and (token='LIMIT') then
2162 begin
2163 gettoken;
2164 limit:=NExpression;
2165 {if limit=nil then fail}
2166 end;
2167 checktoken(':',IDH_MAT_PLOT);
2168 try
2169 mat:=Nmatrix; {nil���������}
2170 if (mat<>nil) and (mat.idr.dim=1) then
2171 begin
2172 check(',',IDH_MAT_PLOT);
2173 mat2:=Nmatrix;
2174 end;
2175 except
2176 on ERecompile do raise;
2177 else;
2178 end;
2179 if (mat<>nil) and (mat.idr.dim=1) and (mat2<>nil) and (mat2.idr.dim=1)
2180 or (mat<>nil) and (mat.idr.dim=2) then
2181 else
2182 begin seterrdimension(IDH_MAT);{done;fail} end;
2183 end;
2184 *)
2185
2186 constructor TPlotOrg.createmat(prev,eld:TStatement; plot:boolean); //2011.3.5
2187 begin
2188 graphmode:=true;
2189 inherited create(prev,eld);
2190 GRAPHst:=not plot;
2191 gettoken; {POINTS, etc.}
2192 if test(',') and (token='LIMIT') then
2193 begin
2194 gettoken;
2195 limit:=NExpression;
2196 {if limit=nil then fail}
2197 end;
2198 checktoken(':',IDH_MAT_PLOT);
2199 try
2200 mat:=Nmatrix; {nil���������}
2201 if (mat<>nil) and (mat.idr.dim=1)
2202 and ((programunit.Arithmetic<>precisionComplex) or (token=',')) then
2203 begin
2204 check(',',IDH_MAT_PLOT);
2205 mat2:=Nmatrix;
2206 end;
2207 except
2208 on ERecompile do raise;
2209 else;
2210 end;
2211 if (mat<>nil) and (mat.idr.dim=1) and (mat2<>nil) and (mat2.idr.dim=1)
2212 or (mat<>nil) and (mat.idr.dim=1) and (programunit.Arithmetic=precisionComplex)
2213 or (mat<>nil) and (mat.idr.dim=2)then
2214 else
2215 begin seterrdimension(IDH_MAT);{done;fail} end;
2216 end;
2217
2218
2219
2220 constructor TMatPlotLines.create(prev,eld:TStatement; plot:boolean);
2221 begin
2222 inherited create(prev,eld,plot);
2223 if (token=';') and plot then
2224 begin
2225 gettoken;
2226 cont:=true;
2227 end
2228 else
2229 cont:=false;
2230 end;
2231
2232 constructor TPlotArea.create(prev,eld:TStatement; plot:boolean);
2233 begin
2234 inherited create(prev,eld,plot);
2235 if not (pointpairs.count>=2*3) then
2236 seterr('',IDH_AREA);
2237 end;
2238
2239
2240 destructor TPlotOrg.destroy;
2241 begin
2242 pointpairs.free;
2243 limit.free;
2244 mat.free;
2245 inherited destroy
2246 end;
2247 (*
2248 function TPlotOrg.evalLimit:integer;
2249 begin
2250 if pointpairs<>nil then
2251 result:=Pointpairs.count div 2
2252 else if mat<>nil then
2253 begin
2254 result:=maxint;
2255 if limit<>nil then
2256 result:=limit.evalInteger;
2257 result:=min(result, TArray(mat.point).Size[1]);
2258 if mat2=nil then
2259 begin
2260 if TArray(mat.point).size[2]<2 then
2261 setexception(6401)
2262 end
2263 else
2264 if TArray(mat2.point).size[1]<result then
2265 setexception(6401);
2266 end;
2267 end;
2268
2269 function TPlotOrg.MakeList(p:PPointArray; lim:integer):integer; //���������������������
2270 var
2271 index:integer;
2272 x,y:extended;
2273 array1,array2:TArray;
2274 begin
2275 index:=0;
2276 if pointpairs<>nil then
2277 with PointPairs do
2278 begin
2279 result:=0;
2280 while index<lim do
2281 begin
2282 x:=TPrincipal(items[index*2 ]).evalX;
2283 y:=TPrincipal(items[index*2+1]).evalX;
2284 inc(index);
2285 if GRAPHst or currenttransform.transform(x,y) then
2286 begin
2287 p^[result].x:=restrict(MyGraphSys.deviceX(x));
2288 p^[result].y:=restrict(MyGraphSys.deviceY(y));
2289 inc(result);
2290 end
2291 end
2292 end
2293 else if (mat<>nil) and (mat2=nil) then
2294 with TArray(mat.point) do
2295 begin
2296 result:=0;
2297 while index<lim do
2298 begin
2299 ItemGetX(index*size[2], x);
2300 ItemGetX(Index*size[2]+1,y);
2301 inc(index);
2302 if GRAPHst or currenttransform.transform(x,y) then
2303 begin
2304 p^[result].x:=restrict(MyGraphSys.deviceX(x));
2305 p^[result].y:=restrict(MyGraphSys.deviceY(y));
2306 inc(result)
2307 end
2308 end;
2309 end
2310 else if (mat<>nil) and (mat2<>nil) then
2311 begin
2312 array1:=TArray(mat.point);
2313 array2:=TArray(mat2.point);
2314 result:=0;
2315 while index<lim do
2316 begin
2317 array1.ItemGetX(index,x);
2318 array2.ItemGetX(index,y);
2319 inc(index);
2320 if GRAPHst or currenttransform.transform(x,y) then
2321 begin
2322 p^[result].x:=restrict(MyGraphSys.deviceX(x));
2323 p^[result].y:=restrict(MyGraphSys.deviceY(y));
2324 inc(result);
2325 end
2326 end
2327 end
2328 end;
2329
2330 procedure TPlotOrg.MakeCoordinateList(p:PCoordinateArray; lim:integer); //������������������
2331 var
2332 index:integer;
2333 array1,array2:TArray;
2334 begin
2335 index:=0;
2336 if pointpairs<>nil then
2337 with PointPairs do
2338 begin
2339 while index<lim do
2340 begin
2341 p^[index].x:=TPrincipal(items[index*2 ]).evalX;
2342 p^[index].y:=TPrincipal(items[index*2+1]).evalX;
2343 inc(index);
2344 end
2345 end
2346 else if (mat<>nil) and (mat2=nil) then
2347 with TArray(mat.point) do
2348 begin
2349 while index<lim do
2350 begin
2351 ItemGetX(index*size[2], p^[index].x);
2352 ItemGetX(Index*size[2]+1, p^[index].y);
2353 inc(index);
2354 end;
2355 end
2356 else if (mat<>nil) and (mat2<>nil) then
2357 begin
2358 array1:=TArray(mat.point);
2359 array2:=TArray(mat2.point);
2360 while index<lim do
2361 begin
2362 array1.ItemGetX(index, p^[index].x);
2363 array2.ItemGetX(index, p^[index].y);
2364 inc(index);
2365 end
2366 end
2367 end;
2368
2369 function TPlotOrg.ReMakeList(p:PCoordinateArray; q:PPointArray; count:integer):integer; //���������������������
2370 var
2371 i,index:integer;
2372 x,y:extended;
2373 begin
2374 result:=0;
2375 for i:=0 to count-1 do
2376 begin
2377 x:=p^[i].x;
2378 y:=p^[i].y;
2379 if GRAPHst or currenttransform.transform(x,y) then
2380 begin
2381 q^[result].x:=restrict(MyGraphSys.deviceX(x));
2382 q^[result].y:=restrict(MyGraphSys.deviceY(y));
2383 inc(result)
2384 end
2385 end;
2386 end;
2387
2388
2389 procedure TMatPlotPoints.exec;
2390 var
2391 p:PPointArray;
2392 i:integer;
2393 count:integer;
2394 begin
2395 with MyGraphSys do
2396 if BeamMode=bmRigorous then beam:=false;
2397 count:=evalLimit;
2398 GetMem(p, count*sizeof(TPoint));
2399 try
2400 for i:=0 to MakeList(p,count)-1 do
2401 MyGraphSys.putMark0(p^[i].x, p^[i].y);
2402 finally
2403 Freemem(p,count*sizeof(TPoint));
2404 end;
2405 end;
2406
2407
2408 procedure TMatPlotLines.exec;
2409 var
2410 p:PPointArray;
2411 i,index:integer;
2412 count:integer;
2413 begin
2414 MyGraphSys.beam:=false;
2415 count:=evalLimit;
2416 if GRAPHst and (count<2) then
2417 setexception(11100);
2418 if GRAPHst or (CurrentTransform=nil) or CurrentTransform.IsAffine then
2419 begin
2420 GetMem(p,count*sizeof(TPoint));
2421 try
2422 MyGraphSys.PolyLine(slice(p^,MakeList(p,count)));
2423 finally
2424 Freemem(p,count*sizeof(TPoint));
2425 end;
2426 end
2427 else
2428 PlotProjectiveLine(count);
2429
2430 IdleImmediately;
2431 MyGraphSys.beam:=false;
2432 end;
2433
2434 procedure TPlotorg.PlotProjectiveLine(lim:integer);
2435 var
2436 index:integer;
2437 p:PCoordinateArray;
2438 begin
2439 GetMem(p, lim*SizeOf(TCoordinate));
2440 try
2441 MakeCoordinateList(p, lim);
2442 for index:=0 to lim-1 do
2443 with p^[index] do ProjectivePlotTo(x,y);
2444 finally
2445 FreeMem(p, lim*SizeOf(TCoordinate));
2446 end;
2447 end;
2448
2449 procedure TPlotArea.exec;
2450 var
2451 p:PPointArray;
2452 i:integer;
2453 count:integer;
2454 begin
2455 with MyGraphSys do
2456 if BeamMode=bmRigorous then beam:=false;
2457 count:=evalLimit;
2458 if count<3 then setexception(11100);
2459
2460 if GRAPHst or (CurrentTransform=nil) or CurrentTransform.IsAffine then
2461 begin
2462 GetMem(p,count*sizeof(TPoint));
2463 try
2464 MyGraphSys.Polygon(slice(p^,MakeList(p,count)));
2465 finally
2466 Freemem(p,count*sizeof(TPoinT));
2467 end
2468 end
2469 else
2470 ProjectivePolygon(count)
2471 ;
2472 IdleImmediately;
2473 end;
2474
2475
2476 function Inner(x,y:extended; p:PCoordinateArray; count:integer):boolean;
2477 var
2478 i:integer;
2479 x0,y0,x1,y1,y2:extended;
2480 xt:extended;
2481 begin
2482 if (p^[0].x = p^[count-1].x) and (p^[0].y = p^[count-1].y) then dec(count);
2483
2484 result:=false;
2485
2486 for i:=0 to count -1 do
2487 begin
2488 x0:=p^[i].x;
2489 y0:=p^[i].y;
2490 x1:=p^[(i+1) mod count].x;
2491 y1:=p^[(i+1) mod count].y;
2492 y2:=p^[(i+2) mod count].y;
2493
2494 if (y0 - y) * (y - y1) >0 then
2495 begin
2496 xt:=(x1-x0)/(y1-y0)*(y-y0)+x0;
2497 if x=xt then begin result:=true; exit end
2498 else if x<xt then result:=not result;
2499 end
2500 else if y=y1 then
2501 begin
2502 if (y0=y1) then
2503 begin
2504 if ((x -x0)*(x - x1)<=0) then
2505 begin result:=true ; exit end ;
2506 end
2507 else if (y=y1) and ((y0 - y1)*(y1 - y2)>0) then
2508 begin
2509 if x<x1 then result:= not result
2510 end
2511 end
2512 end;
2513 end;
2514
2515 procedure TPlotArea.ProjectivePolygon(lim:integer);
2516 var
2517 p:PCoordinateArray;
2518 q:PPointArray;
2519 a,b:integer;
2520 x,y,yy:extended;
2521 begin
2522 GetMem(p, lim*SizeOf(TCoordinate));
2523 try
2524 MakeCoordinateList(p,lim);
2525 if TestNormalSegments(p,lim) then
2526 begin
2527 GetMem(q,lim*sizeof(TPoint));
2528 try
2529 MyGraphSys.Polygon(slice(q^,ReMakeList(p,q,lim)));
2530 finally
2531 Freemem(q,lim*sizeof(TPoinT));
2532 end
2533 end
2534 else
2535 with MyGraphSys do
2536 for b:=ClipRect.top to Cliprect.Bottom do
2537 begin
2538 yy:=virtualY(b);
2539 for a:=ClipRect.Left to Cliprect.Right do
2540 begin
2541 x:=virtualX(a);
2542 y:=yy;
2543 if currenttransform.invtransform(x,y) then
2544 if inner(x,y,p,lim) then
2545 PutColor(a,b,areacolor);
2546 end;
2547 end;
2548 finally
2549 FreeMem(p, lim*SizeOf(TCoordinate));
2550 end;
2551
2552 end;
2553 *)
2554
2555 constructor TPlotBezier.create(prev,eld:TStatement; plot:boolean);
2556 var
2557 i:integer;
2558 begin
2559 inherited create(prev,eld);
2560 GRAPHst:=not plot;
2561 for i:=0 to 3 do
2562 begin
2563 expx[i]:=NExpression;
2564 check(',',0);
2565 expy[i]:=NExpression;
2566 if i<3 then check(';',0);
2567 end;
2568 end;
2569
2570 destructor TPlotBezier.destroy;
2571 var
2572 i:integer;
2573 begin
2574 for i:=3 downto 0 do
2575 begin
2576 expy[i].Free;
2577 expx[i].Free;
2578 end;
2579 inherited destroy;
2580 end;
2581 (*
2582 procedure TPlotBezier.exec;
2583 var
2584 i:integer;
2585 x,y:extended;
2586 points:Array[0..3]of TPoint;
2587 begin
2588 for i:=0 to 3 do
2589 begin
2590 x:=expx[i].evalX;
2591 y:=expy[i].evalX;
2592 if GraphSt or CurrentTransform.transform(x,y) then
2593 begin
2594 points[i].X:=MyGraphSys.deviceX(x);
2595 points[i].Y:=MyGraphsys.deviceY(y);
2596 end;
2597 end;
2598 MyGraphSys.PolyBezier(Points);
2599 end;
2600 *)
2601
2602
2603
2604 {*********}
2605 {MAT CELLS}
2606 {*********}
2607 type
2608 TMatCells=class(TStatement)
2609 exp1,exp2,exp3,exp4:tPrincipal;
2610 mat1:TMatrix;
2611 GRAPHst:boolean;
2612 constructor create(prev,eld:TStatement);
2613 //procedure exec;override;
2614 destructor destroy;override;
2615 function Code:AnsiString;override;
2616 end;
2617
2618 constructor TMatCells.create(prev,eld:TStatement);
2619 begin
2620 graphmode:=true;
2621 inherited create(prev,eld);
2622 GRAPHst:=not (PrevToken='PLOT');
2623 gettoken; // CELLS
2624 CheckToken(',',IDH_MAT_CELLS);
2625 CheckToken('IN',IDH_MAT_CELLS);
2626 exp1:=Nexpression;
2627 CheckToken(',',IDH_MAT_CELLS);
2628 exp2:=Nexpression;
2629 CheckToken(';',IDH_MAT_CELLS);
2630 exp3:=Nexpression;
2631 CheckToken(',',IDH_MAT_CELLS);
2632 exp4:=Nexpression;
2633 CheckToken(':',IDH_MAT_CELLS);
2634 mat1:=NMatrix;
2635 if mat1.idr.dim<>2 then seterrDimension(IDH_MAT_CELLS);
2636 end;
2637
2638 destructor TMatCells.destroy;
2639 begin
2640 exp1.free;
2641 exp2.free;
2642 exp3.free;
2643 exp4.free;
2644 mat1.free;
2645 inherited destroy;
2646 end;
2647
2648 (*
2649 procedure TMatCells.exec;
2650 var
2651 a,b,i,j:integer;
2652 color:longint;
2653 x,y,x1,y1,x2,y2,w,h:extended;
2654 xx,yy,dx,dy:extended;
2655 p:TArray;
2656 colorbyte:^byte;
2657 svDrawMode:boolean;
2658 PaletteDisabled:boolean;
2659 red,green,blue:byte;
2660 Points:array[1..4]of TPoint;
2661 a1,b1,a2,b2,a3,b3,a4,b4:extended;
2662 begin
2663
2664 x1:=exp1.evalX;
2665 y1:=exp2.evalX;
2666 x2:=exp3.evalX;
2667 y2:=exp4.evalX;
2668
2669 p:=nil;
2670 TVar(p):=Mat1.point;
2671 if p=nil then exit;
2672
2673
2674 if (MyGraphSys is TScreenBMPGraphSys)
2675 and ((CurrentTransform=nil)
2676 or CurrentTransform.IsAffine and (abs(CurrentTransform.det)>1/1024)) then
2677 begin
2678
2679 PaletteDisabled:=MyPalette.PaletteDisabled;
2680 svDrawMode:=GraphSys.HiddenDrawMode;
2681 MyGraphSys.SetHiddenDrawMode(true);
2682
2683 x:=MyGraphSys.virtualX(0);
2684 y:=MyGraphSys.virtualY(0);
2685 dx:=MyGraphSys.virtualX(1);
2686 dy:=MyGraphSys.virtualY(1);
2687 if not GRAPHst then
2688 begin
2689 currenttransform.invtransform(x,y);
2690 currenttransform.invtransform(dx,dy);
2691 end;
2692 dx:=dx-x;
2693 dy:=y-dy;
2694
2695 if (x2-x1)*dx<0 then
2696 dx:=-dx;
2697 if (y2-y1)*dy<0 then
2698 dy:=-dy;
2699 w:=p.size[1]/(x2-x1+dx);
2700 h:=p.size[2]/(y2-y1+dy);
2701
2702 with TScreenBMPGraphSys(MyGraphSys) do
2703 for b:=ClipRect.top to Cliprect.Bottom do
2704 begin
2705 y:=virtualY(b);
2706 yy:=y;
2707 for a:=ClipRect.Left to Cliprect.Right do
2708 begin
2709 x:=virtualX(a);
2710 y:=yy;
2711 if not GRAPHst then
2712 currenttransform.invtransform(x,y);
2713 i:=floor(w*(x-x1)+1e-9 {���������������������});
2714 j:=floor(h*(y-y1)+1e-9 {���������������������});
2715
2716 if (i>=0) and (i<p.size[1]) and (j>=0) and (j<p.size[2]) then
2717 begin
2718 with p do color:=ItemEvaLInteger(i*size[2]+j);
2719 if (color>=0) and
2720 ((color<=maxcolor) or PaletteDisabled) then
2721 begin
2722 if not PaletteDisabled then
2723 color:=MyPalette[color];
2724 Bitmap1.Canvas.pixels[a,b]:=color;
2725 end;
2726 end;
2727
2728
2729
2730
2731
2732 end;
2733 end;
2734 MyGraphSys.setHiddenDrawMode(SvDrawMode);
2735 end
2736 else if (CurrentTransform<>nil) and (abs(CurrentTransform.det)>1/1024) and
2737 ((MyGraphSys is TScreenBMPGraphSys) or
2738 not (NormalSegment(x1,y1,x1,y2)
2739 and NormalSegment(x1,y2,x2,y2)
2740 and NormalSegment(x2,y2,x2,y1)
2741 and NormalSegment(x2,y1,x1,y1))) then
2742 begin
2743 w:=(p.size[1]-0.0001)/(x2-x1);
2744 h:=(p.size[2]-0.0001)/(y2-y1);
2745
2746 with MyGraphSys do
2747 for b:=ClipRect.top to Cliprect.Bottom do
2748 begin
2749 yy:=virtualY(b);
2750 for a:=ClipRect.Left to Cliprect.Right do
2751 begin
2752 x:=virtualX(a);
2753 y:=yy;
2754 if currenttransform.invtransform(x,y) then
2755 try
2756 i:=floor(w*(x-x1)+1e-9 {���������������������});
2757 j:=floor(h*(y-y1)+1e-9 {���������������������});
2758 if (i>=0) and (i<p.size[1]) and (j>=0) and (j<p.size[2]) then
2759 begin
2760 with p do color:=ItemEvaLInteger(i*size[2]+j);
2761 PutColor(a,b,color);
2762 end;
2763 except
2764 end;
2765 end;
2766 end;
2767 end
2768 else
2769 begin
2770 w:=(x2-x1)/p.size[1];
2771 h:=(y2-y1)/p.size[2];
2772 x:=x1;
2773 y:=y1;
2774 for i:=0 to p.size[1]-1 do
2775 begin
2776 for j:=0 to p.size[2]-1 do
2777 begin
2778 with p do color:=ItemEvalInteger(i*size[2]+j);
2779 x:=x1+w*i; xx:=x+w;
2780 y:=y1+h*j; yy:=y+h;
2781 a1:=x; b1:=y;
2782 a2:=xx;b2:=y;
2783 a3:=xx;b3:=yy;
2784 a4:=x; b4:=yy;
2785 if GRAPHst or
2786 currenttransform.transform(a1,b1) and
2787 currenttransform.transform(a2,b2) and
2788 currenttransform.transform(a3,b3) and
2789 currenttransform.transform(a4,b4) then
2790 begin
2791 with MyGraphSys do
2792 begin
2793 Points[1].x:=DeviceX(a1); Points[1].y:=DeviceY(b1);
2794 Points[2].x:=DeviceX(a2); Points[2].y:=DeviceY(b2);
2795 Points[3].x:=DeviceX(a3); Points[3].y:=DeviceY(b3);
2796 Points[4].x:=DeviceX(a4); Points[4].y:=DeviceY(b4);
2797 end;
2798 MyGraphsys.ColorPolygon( Points, color);
2799 end;
2800 end;
2801 end;
2802 end
2803 end;
2804 *)
2805
2806 function MATPLOTst(prev,eld:TStatement):TStatement;
2807 var
2808 plot:boolean;
2809 begin
2810 plot:=(PrevToken='PLOT');
2811 MATPLOTst:=nil;
2812 if token='POINTS' then
2813 MATPLOTst:=TMatPlotPoints.createmat(prev,eld,plot)
2814 else if token='LINES' then
2815 MATPLOTst:=TMatPlotLines.createmat(prev,eld,plot)
2816 else if token='AREA' then
2817 MATPLOTst:=TPLOTAREA.createmat(prev,eld,plot)
2818 else if token='CELLS' then
2819 MATPLOTst:=TMatCells.create(prev,eld)
2820 else
2821 seterr('',IDH_MAT_PLOT);
2822 end;
2823
2824
2825
2826
2827 {*****}
2828 {mouse}
2829 {*****}
2830
2831
2832 type
2833 TGetPoint=class(TStatement)
2834 exp1,exp2:TVariable;
2835 LocateSt:boolean;
2836 NoBeamOff:boolean;
2837 dev1,exp3,exp4:TPrincipal;
2838 constructor create(prev,eld:TStatement; get:boolean);
2839 //procedure exec;override;
2840 destructor destroy;override;
2841 function Code:ansistring;override;
2842 end;
2843
2844
2845 function GETst(prev,eld:TStatement):TStatement;
2846 begin
2847 graphmode:=true;
2848 GETst:=TGETPOINT.create(prev,eld,PrevToken='GET');
2849 end;
2850
2851
2852 constructor TGetPoint.create(prev,eld:TStatement; get:boolean);
2853 begin
2854 inherited create(prev,eld);
2855 LocateSt:=not get;
2856 checktoken('POINT',IDH_GET);
2857 if test('(') then
2858 begin
2859 dev1:=NExpression;
2860 check(')',IDH_LOCATE)
2861 end;
2862 if (token=',') and (nexttoken='AT') then
2863 begin
2864 gettoken;
2865 gettoken;
2866 exp3:=NExpression;
2867 check(',',IDH_GET);
2868 exp4:=NExpression;
2869 end;
2870 if (token=',') and (nexttoken='NOBEAMOFF') then
2871 begin
2872 Gettoken;
2873 Gettoken;
2874 NoBeamOff:=true;
2875 end;
2876 checktoken(':',IDH_GET);
2877 exp1:=nvariable;
2878 check(',',IDH_GET);
2879 exp2:=nvariable;
2880
2881 if exp1 is TSubstance then
2882 TSubstance(exp1).AddQueryInteger(nil); //Integer���������
2883 if exp2 is TSubstance then
2884 TSubstance(exp2).AddQueryInteger(nil); //Integer���������
2885
2886 end;
2887
2888
2889 destructor TGetPoint.destroy;
2890 begin
2891 exp1.free;
2892 exp2.free;
2893 dev1.free;
2894 exp3.free;
2895 exp4.Free;
2896 inherited destroy;
2897 end;
2898
2899 procedure PointAt(exp3,exp4:TPrincipal);
2900 var
2901 x,y:Extended;
2902 vx,vy:integer;
2903 begin
2904 x:=exp3.evalX;
2905 y:=exp4.evalX;
2906 if CurrentTransform.transform(x,y) then
2907 begin
2908 vx:=MyGraphSys.deviceX(x);
2909 vy:=MyGraphSys.deviceY(y);
2910 MyGraphSys.MoveMouse(vx,vy);
2911 end;
2912 end;
2913
2914 (*
2915 procedure TGetPoint.exec;
2916 var
2917 x,y:extended;
2918 vx,vy:integer;
2919 begin
2920 if (dev1<>nil) and (dev1.evalInteger<>1) then
2921 setexception(11152);
2922
2923 if exp3<>nil then
2924 PointAt(exp3,exp4);
2925
2926 SelectLine(TextHand.memo,LineNumb);
2927 with MyGraphSys do
2928 beam:=beam and ((BeamMode=bmImmortal) or NoBeamOff);
2929 MyGraphSys.getpoint(vx,vy);
2930 x:=MyGraphSys.virtualX(vx);
2931 y:=MyGraphSys.virtualY(vy);
2932 if LOCATEst or currenttransform.invtransform(x,y) then
2933 begin
2934 exp1.assignX(x) ;
2935 exp2.assignX(y) ;
2936 end
2937 else
2938 setexception(-3009)
2939 end;
2940 *)
2941
2942 function TGetPoint.Code:ansistring;
2943 begin
2944 result:='';
2945 if exp3<>nil then
2946 result:='PointAt('+exp3.code+','+exp4.code+','+TruthLiteral(Locatest)+');';
2947 result:=result+'GetPoint('+exp1.code+','+exp2.code+','
2948 +truthLiteral(NoBeamOff)+','+TruthLiteral(Locatest)+');'
2949 end;
2950
2951
2952
2953
2954
2955 {**********}
2956 {MOUSE POLL}
2957 {**********}
2958
2959 type
2960 TMousePoll=class(TStatement)
2961 exp1,exp2,exp3,exp4:TVariable;
2962 constructor create(prev,eld:TStatement);
2963 //procedure exec;override;
2964 destructor destroy;override;
2965 function Code:ansistring;override;
2966 end;
2967
2968
2969 function MOUSEst(prev,eld:TStatement):Tstatement;
2970 begin
2971 MOUSEst:=nil;
2972 checktoken('POLL',IDH_EXTENSION);
2973 MOUSEst:=TmousePoll.create(prev,eld);
2974 graphmode:=true;
2975 end;
2976
2977 constructor TMOusePoll.create(prev,eld:TStatement);
2978 begin
2979 inherited create(prev,eld);
2980 exp1:=nvariable;
2981 check(',',IDH_EXTENSION);
2982 exp2:=nvariable;
2983 check(',',IDH_EXTENSION);
2984 exp3:=nvariable;
2985 check(',',IDH_EXTENSION);
2986 exp4:=nvariable;
2987
2988 if exp1 is TSubstance then
2989 TSubstance(exp1).AddQueryInteger(nil); //Integer���������
2990 if exp2 is TSubstance then
2991 TSubstance(exp2).AddQueryInteger(nil); //Integer���������
2992 if exp3 is TSubstance then
2993 TSubstance(exp3).AddQueryInteger(nil); //Integer���������
2994 if exp4 is TSubstance then
2995 TSubstance(exp4).AddQueryInteger(nil); //Integer���������
2996
2997 end;
2998
2999 destructor TMousePoll.destroy;
3000 begin
3001 exp1.free;
3002 exp2.free;
3003 exp3.free;
3004 exp4.free;
3005 inherited destroy
3006 end;
3007
3008
3009 (*
3010 procedure TMousePoll.exec;
3011 var
3012 vx,vy:integer;
3013 x,y:extended;
3014 left,right:boolean;
3015 begin
3016 MyGraphSys.MousePol(vx,vy,left,right);
3017 x:=MyGraphSys.virtualX(vx);
3018 y:=MyGraphSys.virtualY(vy);
3019 if currenttransform.invtransform(x,y) then
3020 begin
3021 exp1.assignX(x);
3022 exp2.assignX(y);
3023 exp3.assignLongint(byte(left));
3024 exp4.assignLongint(byte(right));
3025 end
3026 else
3027 setexception(-3009)
3028 end;
3029 *)
3030 function TMousePoll.Code:ansistring;
3031 begin
3032 result:='MousePoll('+exp1.Code+','+exp2.Code+','+exp3.code+','+exp4.Code+');'
3033 end;
3034
3035
3036 {***************}
3037 {CLEAR statement}
3038 {***************}
3039
3040 type
3041 TCLEAR=class(TSTATEMENT)
3042 //procedure exec;override;
3043 function Code:ansistring;override;
3044 end;
3045 (*
3046 procedure TCLEAR.exec;
3047 begin
3048 if MyGraphSys<>nil then MyGraphSys.clear;
3049 end;
3050 *)
3051 function CLEARst(prev,eld:TStatement):TStatement;
3052 begin
3053 CLEARst:=TCLEAR.create(prev,eld);
3054 end;
3055
3056 {********}
3057 {GLOAD st}
3058 {********}
3059
3060 type
3061 TGLoad=class(TStatement)
3062 exp1:TPrincipal;
3063 constructor create(prev,eld:TStatement);
3064 //procedure exec;override;
3065 destructor destroy;override;
3066 function Code:AnsiString;override;
3067 end;
3068
3069 constructor TGLoad.create(prev,eld:TStatement);
3070 begin
3071 inherited create(prev,eld);
3072 exp1 :=SExpression;
3073 end;
3074
3075 destructor TGLoad.destroy;
3076 begin
3077 exp1.free;
3078 inherited destroy
3079 end;
3080
3081 (*
3082 procedure TGLoad.exec;
3083 var
3084 s:ansistring;
3085 begin
3086 s:=exp1.evalS;
3087 with MyGraphSys do
3088 begin
3089 try
3090 MyGraphSys.OpenFile(s)
3091 except
3092 setexception(9051)
3093 end;
3094 end;
3095 end;
3096 *)
3097 function TGLoad.Code:AnsiString;
3098 begin
3099 Result:='MyGraphSys.OpenFile('+exp1.Code+');'
3100 end;
3101
3102
3103 function GLOADst(prev,eld:TStatement):TStatement;
3104 begin
3105 graphMode:=true;
3106 GLOADst:=TGLoad.create(prev,eld);
3107 end;
3108
3109 type
3110 TGSave=class(TStatement)
3111 exp1,exp2:TPrincipal;
3112 constructor create(prev,eld:TStatement);
3113 //procedure exec;override;
3114 destructor destroy;override;
3115 function Code:AnsiString;override;
3116 end;
3117
3118 constructor TGSave.create(prev,eld:TStatement);
3119 begin
3120 inherited create(prev,eld);
3121 exp1 :=SExpression;
3122 if token=',' then
3123 begin
3124 gettoken;
3125 exp2:=SExpression;
3126 end;
3127 end;
3128
3129 destructor TGSave.destroy;
3130 begin
3131 exp1.free;
3132 exp2.free;
3133 inherited destroy
3134 end;
3135
3136
3137 (*
3138 procedure TGSave.exec;
3139 var
3140 s1,s2:ansistring;
3141 begin
3142 s2:='';
3143 s1:=exp1.evalS;
3144 if exp2<>nil then
3145 begin
3146 s2:=exp2.evalS;
3147 Lower(s2);
3148 end;
3149 try
3150 if (s2='') or (s2='32bit') then
3151 MyGraphSys.SaveBMPFile(s1)
3152 else if s2='8bit' then
3153 MyGraphSys.SaveFileFormat(s1,pf8bit)
3154 else if s2='1bit' then
3155 MyGraphSys.SaveFileFormat(s1,pf1bit);
3156 except
3157 setexception(9052)
3158 end;
3159 end;
3160 *)
3161 function TGSave.Code:ansistring;
3162 begin
3163 if exp2=nil then
3164 result:='GSAVE('+exp1.Code+','''');'
3165 else
3166 result:='GSAVE('+exp1.Code+','+exp2.code+');'
3167 end;
3168
3169
3170
3171 function GSAVEst(prev,eld:TStatement):TStatement;
3172 begin
3173 GSAVEst:=TGSave.create(prev,eld);
3174 end;
3175
3176
3177
3178
3179 {*******}
3180 {GDEVICE}
3181 {*******}
3182
3183 function GRAPHICSst(prev,eld:TStatement):TStatement;
3184 begin
3185 if token='DEVICE' then
3186 begin
3187 gettoken ;
3188 if token='PRINTER' then
3189 begin
3190 gettoken;
3191 result:=TStatement.create(prev,eld);
3192 NextGraphMode:=PRTDirectMode;
3193 end
3194 {
3195 else if token='METAFILE' then
3196 begin
3197 gettoken;
3198 result:=TStatement.create(prev,eld);
3199 NextGraphMode:=PRTMetaFileMode;
3200 end;
3201 }
3202 end;
3203
3204 end;
3205
3206 {******}
3207 {LOCATE}
3208 {******}
3209 type
3210 TLocate=class(TStatement)
3211 dev1, exp1, exp2, exp3:TPrincipal;
3212 nvar1:tVariable;
3213 sary1:TMatrix;
3214 NoWait:boolean;
3215 constructor create(prev,eld:TStatement);
3216 destructor destroy;override;
3217 end;
3218
3219 TLocateChoice=class(TLocate)
3220 //procedure exec;override;
3221 function Code:AnsiString;override;
3222 end;
3223
3224 TLocateValue=class(TLocate)
3225 //procedure exec;override;
3226 function Code:AnsiString;override;
3227 end;
3228
3229 constructor TLocate.create(prev,eld:TStatement);
3230 var
3231 Valuest:boolean;
3232 begin
3233 inherited create(prev,eld);
3234 Valuest:=false;
3235 if token='VALUE' then
3236 begin
3237 valuest:=true;
3238 if Nexttoken='NOWAIT' then
3239 begin
3240 NoWait:=true;
3241 gettoken;
3242 end;
3243 end;
3244 gettoken;
3245 if test('(') then
3246 begin
3247
3248 if tokenspec=sidf then
3249 sary1:=SMatrixDim(1)
3250 else
3251 dev1:=NExpression;
3252 check(')',IDH_LOCATE)
3253 end;
3254 if Valuest and (token=',') and (nextToken='RANGE') then
3255 begin
3256 gettoken;
3257 gettoken;
3258 exp1:=NExpression;
3259 check('TO',IDH_LOCATE);
3260 exp2:=NExpression;
3261 end;
3262 if test(',') then
3263 begin
3264 check('AT',IDH_LOCATE);
3265 exp3:=NExpression;
3266 end;
3267 check(':',idh_locate);
3268 nvar1:=NVariable;
3269 if nvar1 is TSubstance then
3270 TSubstance(nvar1).AddQueryInteger(nil); //Integer���������
3271
3272 end;
3273
3274 destructor TLocate.destroy;
3275 begin
3276 dev1.Free;
3277 sary1.Free;
3278 exp1.Free;
3279 exp2.Free;
3280 exp3.Free;
3281 nvar1.Free;
3282 inherited destroy;
3283 end;
3284
3285 function TLocateChoice.Code:ansistring;
3286 begin
3287 result:='LocateChoice(';
3288 if dev1<>nil then
3289 begin
3290 result:=result+Dev1.Code+',';
3291 if exp3<>nil then
3292 result:=result+exp3.code+','
3293 end
3294 else if sary1<>nil then
3295 result:=result+sary1.code+',';
3296 result:=result+nvar1.Code+');'
3297 end;
3298
3299 function TlocateValue.Code:AnsiString;
3300 var
3301 name0:ansistring;
3302 begin
3303 if nvar1 is TSubstance then
3304 Name0:=TSubstance(nvar1).idr.name
3305 else
3306 Name0:='';
3307 if nowait then
3308 result:='LocateValueNowait('
3309 else
3310 result:='LocateValue(';
3311 if dev1<>nil then
3312 result:=result+Dev1.Code+','
3313 else
3314 result:=result+'1,' ;
3315 if exp1<>nil then
3316 result:=result+exp1.code+','+exp2.code+',';
3317 if exp3<>nil then
3318 result:=result+exp3.code+',';
3319 result:=result+nvar1.Code+','''+Name0+''');'
3320 end;
3321
3322
3323 function LOCATEst(prev,eld:TStatement):TStatement;
3324 begin
3325 if token='POINT' then
3326 LOCATEst:=GETst(prev,eld)
3327 else if token='CHOICE' then
3328 LOCATEst:=TLocateChoice.create(prev,eld)
3329 else if token='VALUE' then
3330 LOCATEst:=TLocateValue.create(prev,eld)
3331 end;
3332
3333
3334 {**********}
3335 {MAT LOCATE}
3336 {**********}
3337
3338 type
3339 TMatLocate=class(TStatement)
3340 mat1,mat2:TMatrix;
3341 redim1,redim2:TMatRedim;
3342 dev1,exp3,exp4:TPrincipal;
3343 dim:byte;
3344 varilen:boolean;
3345 locatest:boolean;
3346 constructor create(prev,eld:TStatement);
3347 destructor destroy;override;
3348 //procedure exec;override;
3349 function Code:Ansistring;override;
3350 end;
3351
3352 destructor TmatLocate.destroy;
3353 begin
3354 mat1.Free;
3355 mat2.Free;
3356 redim1.free;
3357 redim2.Free;
3358 exp3.Free;
3359 exp4.Free;
3360 dev1.free;
3361 inherited destroy
3362 end;
3363
3364 constructor TmatLocate.create(prev,eld:TStatement);
3365 begin
3366 inherited create(prev,eld);
3367 graphmode:=true;
3368 locatest:=(PrevToken='LOCATE');
3369 CheckToken('POINT',IDH_GET);
3370 if test('(') then //������������
3371 begin
3372 dev1:=NExpression;
3373 check(')',IDH_LOCATE)
3374 end;
3375 if test(',') then //���������
3376 begin
3377 check('AT',IDH_LOCATE);
3378 exp3:=NExpression;
3379 check(',',IDH_GET);
3380 exp4:=NExpression;
3381 end;
3382
3383 check(':',IDH_GET);
3384
3385 mat1:=NMatrix;
3386 //if mat1=nil then raise ESyntaxError.create('');
3387 dim:=Mat1.idr.dim;
3388 if dim>=3 then seterrdimension(Idh_GET);
3389 if token='(' then
3390 if nexttoken='?' then
3391 begin
3392 gettoken;
3393 gettoken;
3394 varilen:=true;
3395 if dim=2 then
3396 check(',',IDH_GET);
3397 check(')',IDH_GET);
3398 end
3399 else
3400 redim1:=TMatRedim.create(mat1,false);
3401
3402 if dim=1 then
3403 begin
3404 check(',',IDH_GET);
3405 mat2:=NMatrixDim(1);
3406 if varilen then
3407 begin
3408 check('(',IDH_GET);
3409 check('?',IDH_GET);
3410 check(')',IDH_GET);
3411 end
3412 else if token='(' then
3413 redim2:=TMatredim.create(mat2,false);
3414 end;
3415
3416 end;
3417 (*
3418 procedure TmatLocate.exec;
3419 var
3420 vx,vy,vx0,vy0:integer;
3421 maxlen:integer;
3422 x,y:extended;
3423 i:integer;
3424 left,right:boolean;
3425 begin
3426 MyGraphsys.beam:=false;
3427 if exp3<>nil then
3428 PointAt(exp3,exp4);
3429
3430 if varilen then
3431 begin
3432 vx0:=low(integer);
3433 vy0:=low(integer);
3434 case dim of
3435 1: maxlen:=min(TArray(mat1.point).MaxSize,TArray(mat2.point).MaxSize);
3436 2: begin
3437 maxlen:=TArray(mat1.point).MaxSize div 2;
3438 TArray(mat1.point).size[2]:=2;
3439 end;
3440 end;
3441 repeat
3442 sleep(10);
3443 MyGraphSys.MousePol(vx,vy,left,right)
3444 until left=false;
3445 repeat
3446 sleep(10);
3447 MyGraphSys.MousePol(vx,vy,left,right)
3448 until left=true;
3449 i:=0;
3450 while (i<maxlen) and (left=true) do
3451 begin
3452 if (vx<>vy0)or(vy<>vy0) then
3453 begin
3454 x:=MyGraphsys.virtualX(vx);
3455 y:=MyGraphsys.VirtualY(vy);
3456 if Locatest or CurrentTransform.InvTransform(x,y) then
3457 case dim of
3458 1:begin
3459 TArray(mat1.point).ItemAssignX(i,x);
3460 TArray(mat2.point).ItemAssignX(i,y);
3461 end;
3462 2:begin
3463 with TArray(mat1.point) do ItemAssignX(i*size[2], x);
3464 with TArray(mat1.point) do ItemAssignX(i*size[2]+1,y);
3465 end;
3466 end
3467 else
3468 setexception(-3009) ;
3469 end;
3470 inc(i);
3471 sleep(20);
3472 MyGraphSys.MousePol(vx,vy,left,right)
3473 end;
3474 if i=maxlen then beep;
3475 case dim of
3476 1:begin
3477 TArray(mat1.point).size[1]:=i;
3478 TArray(mat2.point).size[1]:=i;
3479 end;
3480 2:begin
3481 TArray(mat1.point).size[1]:=i;
3482 end;
3483 end;
3484 end
3485 else
3486 begin //������������������
3487 if redim1<>nil then redim1.exec;
3488 if redim2<>nil then redim2.exec;
3489 case dim of
3490 1:begin
3491 maxlen:=TArray(mat1.point).size[1];
3492 if maxlen<>TArray(mat2.point).size[1] then
3493 setexception(6401);
3494 end;
3495 2:begin
3496 maxlen:=TArray(mat1.point).size[1];
3497 if TArray(mat1.point).size[2]<2 then
3498 setexception(6401);
3499 end;
3500 end;
3501 for i:=0 to maxlen-1 do
3502 begin
3503 MyGraphsys.getpoint(vx,vy);
3504 x:=MyGraphsys.virtualX(vx);
3505 y:=MyGraphsys.VirtualY(vy);
3506 if Locatest or CurrentTransform.InvTransform(x,y) then
3507 case dim of
3508 1:begin
3509 TArray(mat1.point).ItemAssignX(i,x);
3510 TArray(mat2.point).ItemAssignX(i,y);
3511 end;
3512 2:begin
3513 with TArray(mat1.point) do ItemAssignX(i*size[2], x);
3514 with TArray(mat1.point) do ItemAssignX(i*size[2]+1,y);
3515 end;
3516 end
3517 else
3518 setexception(-3009) ;
3519 end;
3520 end;
3521 end;
3522 *)
3523 function TmatLocate.Code:ansistring;
3524 begin
3525 if exp3<>nil then
3526 result:='PointAt('+exp3.code+','+exp4.code+','+truthLiteral(LocateSt)+');'
3527 else
3528 result:='';
3529 if redim1<>nil then result:=result+redim1.code;
3530 if redim2<>nil then result:=result+redim2.code;
3531
3532 if varilen then
3533 result:=result+'MatGetPointVarilen('
3534 else
3535 result:=result+'MatGetPoint(';
3536
3537 result:=result+mat1.code;
3538 if dim=1 then result:=result+',' + mat2.code;
3539
3540 result:=result+','+TruthLiteral(LocateSt)+');'
3541 end;
3542
3543
3544 function MATLOCATEst(prev,eld:TStatement):TStatement;
3545 begin
3546 MATLOCATEst:=TMatLocate.create(prev,eld);
3547 end;
3548
3549 function PixelX(x:extended):extended;
3550 begin
3551 with MyGraphSys do
3552 result:=DeviceX(x) - DeviceX(left);
3553 end;
3554
3555 function PixelY(x:extended):extended;
3556 begin
3557 with MyGraphSys do
3558 result:=DeviceY(bottom) - DeviceY(x)
3559 end;
3560
3561 function WindowX(x:extended):extended;
3562 begin
3563 with MyGraphSys do
3564 result:=VirtualX( DeviceX(left) +
3565 {$IFDEF ver100}system.round{$ELSE}LongIntRound{$ENDIF}(x) )
3566 end;
3567
3568 function WindowY(x:extended):extended;
3569 begin
3570 with MyGraphSys do
3571 result:=VirtualY( DeviceY(bottom) -
3572 {$IFDEF ver100}system.round{$ELSE}LongIntRound{$ENDIF}(x))
3573 end;
3574
3575 {*********}
3576 {Microsoft}
3577 {*********}
3578
3579 function OnlyMSst(prev,eld:TStatement):TStatement;
3580 begin
3581 Seterr(PrevToken + s_MSmodeOnly, IDH_SYNTAX_MICROSOFT) ;
3582 end;
3583
3584
3585 function MSLINEst(prev,eld:TStatement):TStatement;
3586 begin
3587 result:=OnLyMSst(prev,eld);
3588 end;
3589
3590
3591
3592 (*
3593 type
3594 TMSWindow=class(TCustomSetWindow)
3595 constructor create(prev,eld:TStatement);
3596 end;
3597
3598 constructor TMSWindow.create(prev,eld:TStatement);
3599 begin
3600 inherited create(prev,eld);
3601 graphmode:=true;
3602 check( '(',IDH_SYNTAX_MICROSOFT);
3603 x1:=nexpression;
3604 check(',',IDH_SYNTAX_MICROSOFT);
3605 y2:=nexpression;
3606 check(')',IDH_SYNTAX_MICROSOFT);
3607 check('-',IDH_SYNTAX_MICROSOFT);
3608 check('(',IDH_SYNTAX_MICROSOFT);
3609 x2:=nexpression;
3610 check(',',IDH_SYNTAX_MICROSOFT);
3611 y1:=nexpression;
3612 check(')',IDH_SYNTAX_MICROSOFT);
3613 end;
3614
3615 function WINDOWst(prev,eld:TStatement):TStatement;
3616 begin
3617 if PermitMicrosoft then
3618 result:=TMSWINDOW.create(prev,eld)
3619 else
3620 Seterr(s_WINDOW, IDH_WINDOW) ;
3621 end;
3622
3623
3624
3625 type
3626 TPSET=class(TStatement)
3627 exp1,exp2,exp3:TPrincipal;
3628 constructor create(prev,eld:TStatement);
3629 destructor destroy;override;
3630 procedure exec;override;
3631 end;
3632
3633 constructor TPSet.create(prev,eld:TStatement);
3634 begin
3635 graphmode:=true;
3636 inherited create(prev,eld);
3637 Check('(',IDH_SYNTAX_MICROSOFT);
3638 exp1:=nexpression;
3639 check(',',IDH_SYNTAX_MICROSOFT);
3640 exp2:=nexpression;
3641 check(')',IDH_SYNTAX_MICROSOFT);
3642 if test(',') then
3643 exp3:=NExpression;
3644 end;
3645
3646
3647 destructor TPSet.destroy;
3648 begin
3649 exp1.free;
3650 exp2.free;
3651 exp3.free;
3652 inherited destroy
3653 end;
3654
3655
3656 procedure TPSet.exec;
3657 var
3658 a,b,c:integer;
3659 begin
3660 a:=MyGraphSys.DeviceX(exp1.evalX);
3661 b:=MyGraphSys.DeviceY(exp2.evalX);
3662 c:=GetLineColor;
3663 if exp3<>nil then
3664 c:=exp3.evalInteger;
3665 MyGraphSys.MSmoveto(a,b);
3666 MyGraphSys.putColor(a,b,c);
3667
3668
3669 end;
3670
3671 function PSETst(prev,eld:TStatement):TStatement;
3672 begin
3673 result:=TPSET.create(prev,eld);
3674 end;
3675
3676
3677 type
3678 TLINE=class(TStatement)
3679 exp1,exp2,exp3,exp4,exp5:TPrincipal;
3680 BF:char;
3681 constructor create(prev,eld:TStatement);
3682 destructor destroy;override;
3683 procedure exec;override;
3684 end;
3685
3686 constructor TLINE.create(prev,eld:TStatement);
3687 begin
3688 graphmode:=true;
3689 inherited create(prev,eld);
3690 if token<>'-' then
3691 begin
3692 Check('(',IDH_SYNTAX_MICROSOFT);
3693 exp1:=nexpression;
3694 check(',',IDH_SYNTAX_MICROSOFT);
3695 exp2:=nexpression;
3696 check(')',IDH_SYNTAX_MICROSOFT);
3697 end;
3698 check('-',IDH_SYNTAX_MICROSOFT);
3699 Check('(',IDH_SYNTAX_MICROSOFT);
3700 exp3:=nexpression;
3701 check(',',IDH_SYNTAX_MICROSOFT);
3702 exp4:=nexpression;
3703 check(')',IDH_SYNTAX_MICROSOFT);
3704 if test(',') then
3705 begin
3706 if token<>',' then
3707 exp5:=NExpression;
3708 if (token=',') and (exp1<>nil) and (exp2<>nil) then
3709 begin
3710 gettoken;
3711 if token='B' then
3712 begin BF:='B'; gettoken end
3713 else if token='BF' then
3714 begin BF:='F'; gettoken end;
3715 end;
3716 end;
3717 end;
3718
3719
3720 destructor TLINE.destroy;
3721 begin
3722 exp1.free;
3723 exp2.free;
3724 exp3.free;
3725 exp4.free;
3726 exp5.free;
3727 inherited destroy
3728 end;
3729
3730
3731 procedure TLINE.exec;
3732 var
3733 x1,y1,x2,y2:longint;
3734 svLineColor,svareacolor:integer;
3735 p:PPointArray;
3736 begin
3737 if exp1<>nil then x1:=MyGraphSys.DeviceX(exp1.evalX);
3738 if exp2<>nil then y1:=MyGraphSys.DeviceY(exp2.evalX);
3739 x2:=MyGraphSys.DeviceX(exp3.evalX);
3740 y2:=MyGraphSys.DeviceY(exp4.evalX);
3741 svLineColor:=MyGraphSys.LineColor;
3742 if exp5<>nil then setlinecolor(exp5.evalinteger);
3743 case BF of
3744 'B':begin
3745 MyGraphSys.MSmoveto(x1,y1);
3746 MyGraphSys.MSlineto(x1,y2);
3747 MyGraphSys.MSlineto(x2,y2);
3748 MyGraphSys.MSlineto(x2,y1);
3749 MyGraphSys.MSlineto(x1,y1);
3750 end;
3751 'F':begin
3752 svAreaColor:=MyGraphSys.areacolor;
3753 setareacolor(MyGraphSys.linecolor);
3754 GetMem(p,4*sizeof(TPoint));
3755 p^[0].x:=x1;
3756 p^[0].y:=y1;
3757 p^[1].x:=x1;
3758 p^[1].y:=y2;
3759 p^[2].x:=x2;
3760 p^[2].y:=y2;
3761 p^[3].x:=x2;
3762 p^[3].y:=y1;
3763 MyGraphSys.Polygon(slice(p^,4));
3764 Freemem(p,4*sizeof(TPoinT));
3765 setareacolor(svAreaColor);
3766 end;
3767 else
3768 begin
3769 if (exp1=nil) then
3770 MyGraphSys.MSlineto(x2,y2)
3771 else
3772 begin
3773 MyGraphSys.MSmoveto(x1,y1);
3774 MyGraphSys.MSlineto(x2,y2)
3775 end;
3776 end;
3777 end;
3778 setlinecolor(svLinecolor);
3779 end;
3780
3781 function MSLINEst(prev,eld:TStatement):TStatement;
3782 begin
3783 result:=TLINE.create(prev,eld);
3784 end;
3785
3786 function COLORst(prev,eld:TStatement):TStatement;
3787 begin
3788 if test(',') then
3789 begin
3790 checktoken(',',IDH_SYNTAX_MICROSOFT);
3791 checktoken(',',IDH_SYNTAX_MICROSOFT);
3792 if test(',') then
3793 result:=LabelStatement(prev,eld) ;
3794 end;
3795 COLORst:=TSet.createColor(prev,eld,SetLineColor);
3796 end;
3797
3798 procedure MSScreen(c:integer);
3799 begin
3800 MyGraphSys.MSScreen(c);
3801 end;
3802
3803 function SCREENst(prev,eld:TStatement):TStatement;
3804 begin
3805 SCREENst:=TSet.createColor(prev,eld,MSScreen)
3806 end;
3807
3808 procedure CLS(c:integer);
3809 begin
3810 MyGraphSys.clear;
3811 end;
3812
3813 function CLSst(prev,eld:TStatement):TStatement;
3814 begin
3815 CLSst:=TSet.createColor(prev,eld,CLS);
3816 end;
3817
3818
3819
3820 type
3821 TPAINT=class(TStatement)
3822 exp1,exp2,exp3,exp4:TPrincipal;
3823 constructor create(prev,eld:TStatement);
3824 destructor destroy;override;
3825 procedure exec;override;
3826 end;
3827
3828
3829 constructor TPAINT.create(prev,eld:TStatement);
3830 begin
3831 graphmode:=true;
3832 inherited create(prev,eld);
3833 Check('(',IDH_SYNTAX_MICROSOFT);
3834 exp1:=nexpression;
3835 check(',',IDH_SYNTAX_MICROSOFT);
3836 exp2:=nexpression;
3837 check(')',IDH_SYNTAX_MICROSOFT);
3838 if test(',') then
3839 begin
3840 if token<>',' then
3841 exp3:=nexpression;
3842 if test(',') then
3843 exp4:=nexpression;
3844 end;
3845 end;
3846
3847 destructor TPAINT.destroy;
3848 begin
3849 exp1.free;
3850 exp2.free;
3851 exp3.free;
3852 exp4.free;
3853 inherited destroy
3854 end;
3855
3856
3857 procedure TPAINT.exec;
3858 var
3859 a,b:longint;
3860 ac,bc:integer;
3861 begin
3862 a:=MyGraphSys.deviceX(exp1.evalX);
3863 b:=MyGraphSys.deviceY(exp2.evalX);
3864 ac:=getLineColor;
3865 if exp3<>nil then ac:=exp3.evalInteger;
3866 bc:=ac;
3867 if exp4<>nil then bc:=exp4.evalInteger;
3868 MyGraphSys.MSPaint(a,b,ac,bc);
3869
3870 end;
3871
3872 function PAINTst(prev,eld:TStatement):TStatement;
3873 begin
3874 result:=TPaint.create(prev,eld);
3875 end;
3876
3877
3878 type
3879 TCircle=class(TStatement)
3880 exp1,exp2,exp3,exp4,exp7,exp8:TPrincipal;
3881 F:boolean;
3882 constructor create(prev,eld:TStatement);
3883 destructor destroy;override;
3884 procedure exec;override;
3885 end;
3886
3887
3888 constructor TCircle.create(prev,eld:TStatement);
3889 begin
3890 graphmode:=true;
3891 inherited create(prev,eld);
3892 Check('(',IDH_SYNTAX_MICROSOFT);
3893 exp1:=nexpression;
3894 check(',',IDH_SYNTAX_MICROSOFT);
3895 exp2:=nexpression;
3896 check(')',IDH_SYNTAX_MICROSOFT);
3897 check(',',IDH_SYNTAX_MICROSOFT);
3898 exp3:=nexpression;
3899 if test(',') then
3900 begin
3901 if token<>',' then
3902 begin
3903 exp4:=nexpression;
3904 end;
3905 if test(',') then
3906 begin
3907 check(',',IDH_SYNTAX_MICROSOFT);
3908 check(',',IDH_SYNTAX_MICROSOFT);
3909 if token<>',' then
3910 exp7:=NExpression;
3911 if test(',') then
3912 begin
3913 CHECK('F',IDH_SYNTAX_MICROSOFT);
3914 F:=true;
3915 if test(',') then
3916 exp8:=NExpression;
3917 end;
3918 end;
3919 end;
3920 end;
3921
3922 destructor TCircle.destroy;
3923 begin
3924 exp1.free;
3925 exp2.free;
3926 exp3.free;
3927 exp4.free;
3928 exp7.free;
3929 exp8.free;
3930 inherited destroy
3931 end;
3932
3933
3934 procedure TCircle.exec;
3935 var
3936 radius,ratio,rh,rv:extended;
3937 x,y:extended;
3938 x1,y1,x2,y2:integer;
3939 lc,ac:integer;
3940 t:integer;
3941 begin
3942 x:=exp1.evalX;
3943 y:=exp2.evalX;
3944 radius:=exp3.evalX;
3945 if exp4=nil then lc:=getLineColor else lc:=exp4.evalInteger;
3946 if exp7=nil then ratio:=1. else ratio:=abs(exp7.evalX);
3947 if exp8=nil then ac:=lc else ac:=exp8.evalInteger;
3948 if ratio<=1 then
3949 begin rh:=radius; rv:=radius*ratio end
3950 else
3951 begin rh:=radius/ratio; rv:=radius end;
3952 x1:=MyGraphSys.deviceX(x-rh); x2:=MyGraphSys.deviceX(x+rh);
3953 y1:=MyGraphSys.deviceY(y-rv); y2:=MyGraphSys.deviceY(y+rv);
3954 if x1>x2 then begin t:=x1; x1:=x2; x2:=t end;
3955 if y1>y2 then begin t:=y1; y1:=y2; y2:=t end;
3956 MyGraphSys.MSCircle(x1,y1,x2,y2,lc,ac,F);
3957 end;
3958
3959 function CIRCLEst(prev,eld:TStatement):TStatement;
3960 begin
3961 result:=TCircle.create(prev,eld);
3962 end;
3963 *)
3964
3965
3966 type
3967 TFLOOD=class(TStatement)
3968 exp1,exp2:TPrincipal;
3969 constructor create(prev,eld:TStatement);
3970 destructor destroy;override;
3971 //procedure exec;override;
3972 function Code:ansistring;override;
3973 end;
3974
3975
3976 constructor TFLOOD.create(prev,eld:TStatement);
3977 begin
3978 graphmode:=true;
3979 inherited create(prev,eld);
3980 exp1:=nexpression;
3981 check(',',IDH_FLOOD);
3982 exp2:=nexpression;
3983 end;
3984
3985 destructor TFLOOD.destroy;
3986 begin
3987 exp1.free;
3988 exp2.free;
3989 inherited destroy
3990 end;
3991
3992 (*
3993 procedure TFLOOD.exec;
3994 var
3995 x,y:extended;
3996 a,b:longint;
3997 begin
3998 x:=exp1.evalX;
3999 y:=exp2.evalX;
4000 currenttransform.transform(x,y);
4001 a:=MyGraphSys.deviceX(x);
4002 b:=MyGraphSys.deviceY(y);
4003 MyGraphSys.FLOOD(a,b);
4004 end;
4005 *)
4006 function FLOODst(prev,eld:TStatement):TStatement;
4007 begin
4008 result:=TFLOOD.create(prev,eld);
4009 end;
4010
4011 type
4012 TFLOODFILL=class(TFlood)
4013 //procedure exec;override;
4014 function Code:ansistring;override;
4015 end;
4016 (*
4017 procedure TFLOODFILL.exec;
4018 var
4019 x,y:extended;
4020 a,b:longint;
4021 begin
4022 x:=exp1.evalX;
4023 y:=exp2.evalX;
4024 currenttransform.transform(x,y);
4025 a:=MyGraphSys.deviceX(x);
4026 b:=MyGraphSys.deviceY(y);
4027 MyGraphSys.FloodFill(a,b);
4028 end;
4029 *)
4030
4031 function FLOODFILLst(prev,eld:TStatement):TStatement;
4032 begin
4033 result:=TFLOODFILL.create(prev,eld);
4034 end;
4035
4036
4037 {*************}
4038 {Code Generate}
4039 {*************}
4040 function TCustomSetWindow.codesub:ansistring;
4041 begin
4042 result:='('+x1.code+','+x2.code+','+y1.code+','+y2.code+','+TruthLiteral(insideofWhen)+');'
4043 end;
4044
4045
4046 function TSetWindow.Code:AnsiString;
4047 begin
4048 result:='SetWindow'+codesub
4049 end;
4050
4051 function TSetDeviceViewPort.Code:AnsiString;
4052 begin
4053 result:='SetDeviceViewport'+codesub