-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimitives.pas
10500 lines (9319 loc) · 312 KB
/
Primitives.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{+------------------------------------------------------------------------+
| AutoREALM. Copyright (c) 2000, Andrew J. Gryc. |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation; either version 2 of the License, or (at |
| your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| General Public License for more details. |
| |
| For a copy of the GNU General Public License, write to the Free |
| Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 02111-1307, USA. |
+------------------------------------------------------------------------+}
unit Primitives;
interface
uses SysUtils, LCLIntf, Classes, Graphics, Forms, MatrixMath, Math, Geometry,
GraphGrid, DrawLines, DOM, Dialogs;
{ XDOM_2_3, DIMime }
{ LCLIntf provides cross-platform GUI classes }
const IconFontName = 'AutoREALMSymbols';
QuickDraw_Fills=$00000001;
QuickDraw_Lines=$00000002;
QuickDraw_All =$FFFFFFFF;
QuickDraw_None =$00000000;
SelectDistance = 2;
VeryClose = 1E-3; // Used in IsSimilarTo() testing and is intended to handle
// roundoff error
type OverlaySet = set of byte;
HandleMode = (hmAll, hmOne, hmFoundFirst);
HyperlinkFlagValues = (hyperExecute, hyperHidden);
THyperlinkFlags = set of HyperlinkFlagValues;
TextAttribType = (tatText, tatFontName, tatFontSize,
tatFontBold, tatFontItalic, tatFontUnderline,
tatAlignment, tatIconSize, tatOutlineColor,
tatHyperlinkText, tatHyperlinkFlags);
TextAttribSet = set of TextAttribType;
TextAttrib = record
Text:string;
FontName:string;
FontSize:integer;
FontFillColor:TColor;
FontOutlineColor:TColor;
FontBold,FontItalic,FontUnderline:boolean;
Alignment:integer;
Valid:TextAttribSet;
IconSize:integer;
HyperlinkText:string;
HyperlinkFlags:THyperlinkFlags;
end;
PTPoint = ^TPoint;
PDrawPrimitive = ^DrawPrimitive;
{ ----- }
ViewPoint = class
private
Area:CoordRect;
ClientWidth,ClientHeight:integer;
public
Name:string;
Canvas:TCanvas;
VisibleOverlays:OverlaySet;
ActiveOverlays:OverlaySet;
QuickDraw:Cardinal;
Grid:GridObject;
OffScreenFullDetail:boolean;
constructor Create; overload;
constructor Create(rect:CoordRect; cw,ch:integer); overload;
constructor Create(rect:CoordRect; cw,ch:integer; oldgrid:GridObject); overload;
constructor Create(view:ViewPoint; useprinter:boolean=false); overload;
destructor Destroy; override;
procedure CoordToScreen(cx,cy:Coord; var sx,sy:integer); overload;
procedure CoordToScreen(cx,cy:Coord; var sx,sy:Coord); overload;
procedure ScreenToCoord(sx,sy:Coord; var cx,cy:Coord); overload;
procedure ScreenToCoord(sx,sy:integer; var cx,cy:Coord); overload;
procedure DeltaScreenToCoord(dx,dy:integer; var cx,cy:Coord); Overload;
procedure DeltaScreenToCoord(dx,dy:Coord; var cx,cy:Coord); Overload;
procedure DeltaCoordToScreen(cx,cy:Coord; var dx,dy:integer); Overload;
procedure DeltaCoordToScreen(cx,cy:Coord; var dx,dy:Coord); Overload;
function CoordToScreenPt(p:CoordPoint):CoordPoint;
procedure ScreenToCoordPtArray(p:PCoordArray; Count:integer);
procedure Zoom(center:CoordPoint; factor:single; px:single=0.5; py:single=0.5);
procedure SetZoomPercent(percent:double);
function GetZoomPercent:integer;
function CoordToScreenRect(crect:CoordRect):TRect;
function ScreenToCoordRect(rect: TRect): CoordRect; Overload;
function ScreenToCoordRect(rect: CoordRect): CoordRect; Overload;
procedure SetCoordinateSize(width,height:integer; rescale:boolean);
procedure GetCoordinateSize(var width,height:integer);
procedure SetCoordinateRect(cr:CoordRect);
procedure GetCoordinateRect(var cr:CoordRect);
procedure SaveToStream(Stream:TStream);
procedure LoadFromStream(Stream:TStream);
Function GetAsDOMElement(D: TDOMDocument): TDOMElement;
Procedure LoadFromDOMElement(E: TDOMElement);
function FixStyle(st:StyleAttrib):StyleAttrib;
end;
{ ----- }
FractalState = (fsUnchanged, fsSetFractal, fsSetNormal, fsFlipFractal);
{ ----- }
DrawPrimitive = class
private
fOverlay : byte;
fSelected : boolean;
protected
fExtent : CoordRect;
fColor : TColor;
// Absolute X,Y position of the alias. Not used for "base" objects, though
// it is harmless to set it for them.
//
// There are several reasons why Alias contains ABSOLUTE coordinates instead
// of RELATIVE coordinates, all of which relate to GroupPrimitive objects:
//
// 1. Groups don't know where they are.
//
// GroupPrimitive objects neither contain nor use coordinate information;
// they merely contain other DrawPrimitive objects that contain absolute
// coordinates and therefore know where they are. If aliases within a group
// contained relative coordinates, they would need to know the position to
// which they were relative, which means that groups would have to know their
// positions (or be able to get it from their Parents--see below).
//
// 2. The need for "parent" information.
//
// Giving groups positional information is useless unless DrawPrimitives
// know the groups to which they belong. That means adding something like
// a Parent field, and all the necessary code to build this information and
// maintain its integrity. It would also render certain information
// meaningless, such as LinePrimitive (X1,Y1) coordinates, hyperlink
// coordinates, and starting coordinates for curves, polycurves, etc.
//
// 3. SPEED!
//
// Many calculations have to be performed in real-time in which it is
// necessary to know where an alias object's coordinate actually is. For
// instance, dragging a polycurve node requires that the program know where
// that node is in real-time. When alias objects contain absolute
// coordinates, they can simply refer to their base objects and do a fast
// calculation to find out the actual position. When they contain relative
// coordinates, however, they first have to walk a parent tree. I felt that
// this would take far too much time for many operations.
Alias : CoordPoint;
// For a given "base" object, this list contains pointers to all of its
// alias objects. In each alias, this list is empty by definition.
Copies : TStringList;
procedure SetExtent(value:CoordRect);
Procedure MakeCopy(From: DrawPrimitive);
Function MakeAliasView(View: ViewPoint): ViewPoint;
Function GetAdjustedX(X: Coord): Coord;
Function GetAdjustedY(Y: Coord): Coord;
Function GetAdjustedPoint(P: CoordPoint): CoordPoint;
Procedure RecalcAliasFromExtent;
Procedure RefreshCopies;
public
// For alias objects, Base contains a pointer to its "base" object. For
// base objects, this pointer MUST contain Nil (it's how we differentiate
// between base and alias objects).
Base : DrawPrimitive;
Next : DrawPrimitive;
// MapCollection; I can't set the type here because it would cause a
// circular unit reference. We'll just have to typecast it where it's
// used and deal with it. See DrawPrimitive.SetMap() for a full
// explanation of this field's purpose.
MapC : TObject;
Constructor Create;
destructor Destroy; override;
Procedure SetMap(M: TObject); Virtual;
procedure ClearChain;
Procedure InsertIntoBaseList;
Procedure AddToBaseOrCopies(DoChain: Boolean = False); Virtual;
Procedure ClearThis(Deallocate: Boolean); Virtual;
Procedure Clear;
Procedure CopyFromBase(AliasOnly: Boolean); Virtual;
function Copy:DrawPrimitive; virtual;
property Extent:CoordRect read fExtent write SetExtent;
procedure ComputeExtent; virtual;
function IsClosed:boolean; virtual;
procedure SetSize(w,h:Coord);
function Width:Coord;
function Height:Coord;
function IsWithin(rect:CoordRect):boolean;
function IsTouching(rect:CoordRect):boolean;
function IsInOverlay(var overlay:OverlaySet):boolean;
function IsSelected:boolean;
procedure Select(const View:ViewPoint; b:boolean);
function SelectClick(const within:double; p:CoordPoint):boolean; virtual;
function OnScreen(const Coord:CoordRect):boolean;
procedure Invalidate(const Handle: THandle; const View: ViewPoint);
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; virtual;
procedure InvalidateHandle(const Handle: THandle; const View: ViewPoint; x, y: Coord);
procedure DrawHandle(const View:ViewPoint; x,y:Coord);
procedure DrawOverlayHandle(View: ViewPoint; x, y: Coord);
function TestHandle(const View:ViewPoint; tx,ty,px,py:Coord):boolean;
function PointClosestInArray(x,y:Coord; points:PCoordArray; count:integer):integer;
function PointClosestInAdjustedArray(x,y:Coord; points:PCoordArray; count:integer):integer;
function GetLines(const View:Viewpoint; var polycount:integer):PCoordArray; virtual;
function FindHandle(const View:ViewPoint; x,y:Coord):boolean; virtual;
function FindHyperlink(const View:ViewPoint; x,y:Coord; var hypertext:string; var hyperflags:THyperlinkFlags):boolean; virtual;
function FindEndPoint(const View:ViewPoint; var x,y:Coord):boolean; virtual;
Function FindPointOn(Const View: ViewPoint; Var X,Y,Angle: Coord): Boolean; Virtual; // JD 8-3-02
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; virtual;
procedure Move(dx,dy:Coord); virtual;
procedure Draw(View:ViewPoint); virtual;
procedure DrawHandles(const View:ViewPoint); virtual;
procedure DrawOverlayHandles(const View:ViewPoint); virtual;
procedure PointClosestTo(x,y:Coord; var px,py:Coord); virtual;
procedure InvalidateHandles(const Handle: THandle; const View: ViewPoint); virtual;
function FindScalpelPoint(const View:ViewPoint; x,y:Coord; var index:integer):boolean; virtual;
function SeparateNode(const View:ViewPoint; index:integer; var NewObject:DrawPrimitive):boolean; virtual;
procedure DeleteNode(const View:ViewPoint; index:integer); virtual;
function SliceAlong(s1,s2:CoordPoint; var np:DrawPrimitive):boolean; virtual;
function DisplayColor(color:TColor):TColor;
function DisplayFillColor(color:TColor):TColor;
procedure CopyCore(obj:DrawPrimitive);
function ApplyMatrix(var mat:Matrix):boolean; virtual;
function SetStyle(style:StyleAttrib):boolean; virtual;
function GetStyle:StyleAttrib; virtual;
function SetSeed(seed:integer):boolean; virtual;
function GetSeed:integer; virtual;
function SetRoughness(rough:integer):boolean; virtual;
function GetRoughness:integer; virtual;
function SetColor(color:TColor):boolean; virtual;
function GetColor:TColor; virtual;
function SetFillColor(color:TColor):boolean; virtual;
function GetFillColor:TColor; virtual;
function SetOverlay(overlay:byte):boolean; virtual;
function GetOverlay:integer; virtual;
function SetTextAttrib(const View:ViewPoint; const attrib:TextAttrib):boolean; virtual;
function GetTextAttrib:TextAttrib; virtual;
procedure CloseFigure; virtual;
procedure Reverse; virtual;
function SetFractal(state: FractalState): boolean; virtual;
function ChainApplyMatrix(mat:Matrix; all:boolean):boolean;
function ChainExtent(all:boolean):CoordRect;
function ChainSetStyle(style:StyleAttrib; all:boolean):boolean;
function ChainGetStyle(all:boolean):StyleAttrib;
function ChainSetSeed(seed:integer; all:boolean):boolean;
function ChainGetSeed(all:boolean):integer;
function ChainSetRoughness(rough:integer; all:boolean):boolean;
function ChainGetRoughness(all:boolean):integer;
function ChainSetColor(color:TColor; all:boolean):boolean;
function ChainGetColor(all:boolean):TColor;
function ChainSetFillColor(color:TColor; all:boolean):boolean;
function ChainGetFillColor(all:boolean):TColor;
function ChainSetOverlay(overlay:byte; all:boolean):boolean;
function ChainGetOverlay(all:boolean):integer;
function ChainSetTextAttrib(const View:ViewPoint; attrib:TextAttrib; all:boolean):boolean;
function ChainGetTextAttrib(all:boolean):TextAttrib;
function ChainSetFractal(state: FractalState; all: boolean): boolean;
function CountSiblings:integer;
class function ReadChain(stream:TStream; version:integer; selected,Full,UseAliasInfo:boolean; M: TObject):DrawPrimitive;
procedure WriteChain(stream: TStream; all,Full,UseAliasInfo: boolean; AddX: Coord = 0; AddY: Coord = 0);
class function ReadChainFromDOMElement(E: TDOMElement; Version: Integer; Selected: Boolean; M: TObject): DrawPrimitive;
Function GetChainAsDOMElement(D: TDOMDocument; All,Undo: Boolean): TDOMElement;
class function IdToObject(id:char):DrawPrimitive;
function GetId:char; virtual;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); virtual;
procedure Read(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); virtual;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); virtual;
Function ReadBaseFromDOMElement(E: TDOMElement): Boolean;
Function GetAsAliasDOMElement(D: TDOMDocument; E: TDOMElement): Boolean;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Virtual;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Virtual;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Virtual;
Procedure SplitOff;
// procedure FixExtent; virtual;
end;
SymbolPrimitive = class(DrawPrimitive)
public
x1,y1:Coord;
ch,cw,chx:Coord;
Text:string;
Font:TFont;
size:integer;
angle:integer;
fOutlineColor:TColor;
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
Procedure ClearThis(Deallocate: Boolean); Override;
constructor CreateBlank;
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
constructor Create(const View:ViewPoint; ix,iy:Coord; symbol:string; isize:integer; outlinecolor:TColor);
constructor CreateInternal(const View:ViewPoint; ix,iy:Coord; symbol:string; iFont:TFont; outlinecolor:TColor);
procedure ComputeSize(const View:ViewPoint);
function PrepareFont(const View:ViewPoint; var sx,sy:integer; formatflags:integer):boolean;
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
procedure ComputeExtent; override;
procedure Draw(View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
procedure Move(dx,dy:Coord); override;
function GetTextAttrib:TextAttrib; override;
function SetTextAttrib(const View:ViewPoint; const attrib:TextAttrib):boolean; override;
function RotatedBox(w,h:Coord; formatflags:integer):CoordRect;
function SelectClick(const within:double; p:CoordPoint):boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
// procedure FixExtent; override;
end;
TextPrimitive = class(SymbolPrimitive)
formatflags:integer;
public
constructor CreateBlank;
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
constructor Create(const View:ViewPoint; ix,iy:Coord; itext:string; IFont:TFont; iformatflags:integer; outline:TColor);
procedure Draw(View:ViewPoint); override;
procedure ComputeExtent; override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
function SetTextAttrib(const View:ViewPoint; const attrib:TextAttrib):boolean; override;
function GetTextAttrib:TextAttrib; override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
end;
LinePrimitive = class(DrawPrimitive)
public
// Standard attributes
x1,y1,x2,y2:Coord;
style:StyleAttrib;
// Fractal attributes
seed,roughness:integer;
fractal:boolean;
constructor CreateBlank(frac:boolean);
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
// Standard constructor
constructor Create(ix1,iy1,ix2,iy2:Coord; istyle:StyleAttrib); overload;
// Fractal constructor
constructor Create(ix1,iy1,ix2,iy2:Coord; iseed,irough:integer; istyle:StyleAttrib); overload;
// Dual constructor
constructor Create(ix1,iy1,ix2,iy2:Coord; iseed,irough:integer; istyle:StyleAttrib; frac:boolean); overload;
procedure Draw(View:ViewPoint); override;
procedure DrawHandles(const View:ViewPoint); override;
procedure DrawOverlayHandles(const View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function FindHandle(const View:ViewPoint; x,y:Coord):boolean; override;
function FindEndPoint(const View:ViewPoint; var x,y:Coord):boolean; override;
Function FindPointOn(Const View: ViewPoint; Var X,Y,Angle: Coord): Boolean; Override; // JD 8-3-02
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
function SetStyle(new_style:StyleAttrib):boolean; override;
function GetStyle:StyleAttrib; override;
procedure Move(dx,dy:Coord); override;
procedure ComputeExtent; override;
procedure PointClosestTo(x,y:Coord; var px,py:Coord); override;
function SliceAlong(s1,s2:CoordPoint; var np:DrawPrimitive):boolean; override;
procedure Reverse; override;
function GetLines(const View:Viewpoint; var polycount:integer):PCoordArray; override;
// Fractal functions
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
function SetSeed(new_seed:integer):boolean; override;
function GetSeed:integer; override;
function SetRoughness(rough:integer):boolean; override;
function GetRoughness:integer; override;
function RFact:double;
function SetFractal(state: FractalState): boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
Function GetAdjustedX1: Coord;
Function GetAdjustedY1: Coord;
Function GetAdjustedX2: Coord;
Function GetAdjustedY2: Coord;
end;
CurvePrimitive = class(DrawPrimitive)
public
// Standard attributes
p1,p2,p3,p4:CoordPoint;
style:StyleAttrib;
// Fractal attributes
seed,roughness:integer;
fractal:boolean;
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
constructor CreateBlank(frac:boolean);
// Standard constructor
constructor Create(ip1,ip2,ip3,ip4:CoordPoint; istyle:StyleAttrib); overload;
// Fractal constructor
constructor Create(ip1,ip2,ip3,ip4:CoordPoint; iseed,irough:integer; istyle:StyleAttrib); overload;
// Dual constructor
constructor Create(ip1,ip2,ip3,ip4:CoordPoint; iseed,irough:integer; istyle:StyleAttrib; frac:boolean); overload;
procedure Draw(View:ViewPoint); override;
procedure DrawHandles(const View:ViewPoint); override;
procedure InvalidateHandles(const Handle: THandle; const View: ViewPoint); override;
procedure DrawOverlayHandles(const View:ViewPoint); override;
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function FindHandle(const View:ViewPoint; x,y:Coord):boolean; override;
function FindEndPoint(const View:ViewPoint; var x,y:Coord):boolean; override;
Function FindPointOn(Const View: ViewPoint; Var X,Y,Angle: Coord): Boolean; Override; // JD 8-3-02
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
function SetStyle(new_style:StyleAttrib):boolean; override;
function GetStyle:StyleAttrib; override;
procedure Move(dx,dy:Coord); override;
procedure ComputeExtent; override;
procedure PointClosestTo(x,y:Coord; var px,py:Coord); override;
function SliceAlong(s1,s2:CoordPoint; var np:DrawPrimitive):boolean; override;
procedure CloseFigure; override;
procedure Reverse; override;
function GetLines(const View:Viewpoint; var polycount:integer):PCoordArray; override;
function SetSeed(new_seed:integer):boolean; override;
function GetSeed:integer; override;
function SetRoughness(rough:integer):boolean; override;
function GetRoughness:integer; override;
function RFact:double;
function SetFractal(state: FractalState): boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
Function GetAdjustedP1: CoordPoint;
Function GetAdjustedP2: CoordPoint;
Function GetAdjustedP3: CoordPoint;
Function GetAdjustedP4: CoordPoint;
end;
PolyCurvePrimitive = class(DrawPrimitive)
public
// Standard attributes
style:StyleAttrib;
fillcolor:TColor;
points:PCoordArray;
count:integer;
// Fractal attributes
seed,roughness:integer;
fractal:boolean;
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
Procedure ClearThis(Deallocate: Boolean); Override;
constructor CreateBlank(frac:boolean);
// Standard constructor
constructor Create(lp:PCoordArray; c:integer; istyle:StyleAttrib); overload;
// Fractal constructor
constructor Create(lp:PCoordArray; c:integer; iseed,irough:integer; istyle:StyleAttrib); overload;
// Dual constructor
constructor Create(lp:PCoordArray; c:integer; iseed,irough:integer; istyle:StyleAttrib; frac:boolean); overload;
constructor Ellipse(center:CoordPoint; edge:CoordPoint; istyle:StyleAttrib);
// constructor Ellipse(center:CoordPoint; edge:CoordPoint; iseed,irough:integer; istyle:StyleAttrib);
constructor Arc(Center: CoordPoint; Edge1,Edge2: CoordPoint; iStyle: StyleAttrib); // JD 7-31-02
function IsClosed:boolean; override;
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
procedure Draw(View:ViewPoint); override;
procedure DrawHandles(const View:ViewPoint); override;
procedure InvalidateHandles(const Handle: THandle; const View: ViewPoint); override;
procedure DrawOverlayHandles(const View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function FindHandle(const View:ViewPoint; x,y:Coord):boolean; override;
function FindEndPoint(const View:ViewPoint; var x,y:Coord):boolean; override;
Function FindPointOn(Const View: ViewPoint; Var X,Y,Angle: Coord): Boolean; Override; // JD 8-3-02
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
function SetStyle(new_style:StyleAttrib):boolean; override;
function GetStyle:StyleAttrib; override;
procedure Move(dx,dy:Coord); override;
procedure ComputeExtent; override;
procedure PointClosestTo(x,y:Coord; var px,py:Coord); override;
function SetFillColor(color:TColor):boolean; override;
function GetFillColor:TColor; override;
function GetLines(const View:Viewpoint; var polycount:integer):PCoordArray; override;
function SetSeed(new_seed:integer):boolean; override;
function GetSeed:integer; override;
function SetRoughness(rough:integer):boolean; override;
function GetRoughness:integer; override;
procedure CloseFigure; override;
function FindScalpelPoint(const View:ViewPoint; x,y:Coord; var index:integer):boolean; override;
function SeparateNode(const View:ViewPoint; index:integer; var NewObject:DrawPrimitive):boolean; override;
procedure DeleteNode(const View:ViewPoint; index:integer); override;
function SliceAlong(s1,s2:CoordPoint; var np:DrawPrimitive):boolean; override;
procedure Reverse; override;
function SetFractal(state: FractalState): boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
end;
TextCurvePrimitive = class(CurvePrimitive)
Text:string;
Font:TFont;
size:integer;
ch:Coord;
fOutlineColor:TColor;
public
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
constructor CreateBlank;
constructor Create(const View:ViewPoint; ip1,ip2,ip3,ip4:CoordPoint; itext:string; IFont:TFont; outlinecolor:TColor);
procedure Draw(View:ViewPoint); override;
procedure ComputeSize(const View:ViewPoint);
function ApplyMatrix(var mat:Matrix):boolean; override;
procedure ComputeExtent; override;
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
function SetTextAttrib(const View:ViewPoint; const attrib:TextAttrib):boolean; override;
function GetTextAttrib:TextAttrib; override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
Procedure ClearThis(Deallocate: Boolean); Override;
end;
PolyLinePrimitive = class(DrawPrimitive)
public
// Standard attributes
fillcolor:TColor;
points:PCoordArray;
count:integer;
style:StyleAttrib;
// Fractal attributes
seed,roughness:integer;
fractal:boolean;
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
Procedure ClearThis(Deallocate: Boolean); Override;
constructor CreateBlank(frac:boolean);
// Standard constructor
constructor Create(lp:PCoordArray; c:integer; istyle:StyleAttrib); overload;
// Fractal constructor
constructor Create(lp:PCoordArray; c:integer; iseed,irough:integer; istyle:StyleAttrib); overload;
// Dual constructor
constructor Create(lp:PCoordArray; c:integer; iseed,irough:integer; istyle:StyleAttrib; frac:boolean); overload;
function IsClosed:boolean; override;
procedure CloseFigure; override;
function Inside(x,y:Coord):boolean;
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
procedure Draw(View:ViewPoint); override;
procedure DrawHandles(const View:ViewPoint); override;
procedure DrawOverlayHandles(const View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function FindHandle(const View:ViewPoint; x,y:Coord):boolean; override;
function FindEndPoint(const View:ViewPoint; var x,y:Coord):boolean; override;
Function FindPointOn(Const View: ViewPoint; Var X,Y,Angle: Coord): Boolean; Override; // JD 8-3-02
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
function SetStyle(new_style:StyleAttrib):boolean; override;
function GetStyle:StyleAttrib; override;
procedure Move(dx,dy:Coord); override;
procedure ComputeExtent; override;
procedure PointClosestTo(x,y:Coord; var px,py:Coord); override;
function SetFillColor(color:TColor):boolean; override;
function GetFillColor:TColor; override;
function GetLines(const View:Viewpoint; var polycount:integer):PCoordArray; override;
function SliceAlong(s1,s2:CoordPoint; var np:DrawPrimitive):boolean; override;
function FindScalpelPoint(const View:ViewPoint; x,y:Coord; var index:integer):boolean; override;
function SeparateNode(const View:ViewPoint; index:integer; var NewObject:DrawPrimitive):boolean; override;
procedure DeleteNode(const View:ViewPoint; index:integer); override;
procedure Reverse; override;
function SetFractal(state: FractalState): boolean; override;
function SetSeed(new_seed:integer):boolean; override;
function GetSeed:integer; override;
function SetRoughness(rough:integer):boolean; override;
function GetRoughness:integer; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
end;
GroupPrimitive = class(DrawPrimitive)
private
Head : DrawPrimitive;
public
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
Procedure SetMap(M: TObject); Override;
Procedure AddToBaseOrCopies(DoChain: Boolean = False); Override;
constructor CreateBlank;
constructor Create(starting_head:DrawPrimitive);
Procedure ClearThis(Deallocate: Boolean); Override;
function Decompose(const View:ViewPoint; var NewChain:DrawPrimitive; testinside:boolean=true):boolean; override;
property First:DrawPrimitive read head write head;
procedure Draw(View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
procedure Move(dx,dy:Coord); override;
function SetStyle(new_style:StyleAttrib):boolean; override;
function GetStyle:StyleAttrib; override;
function SetSeed(new_seed:integer):boolean; override;
function GetSeed:integer; override;
function SetRoughness(rough:integer):boolean; override;
function GetRoughness:integer; override;
function SetColor(color:TColor):boolean; override;
function GetColor:TColor; override;
function SetOverlay(overlay:byte):boolean; override;
function GetOverlay:integer; override;
function SetTextAttrib(const View:ViewPoint; const attrib:TextAttrib):boolean; override;
function GetTextAttrib:TextAttrib; override;
function SetFillColor(color:TColor):boolean; override;
function GetFillColor:TColor; override;
procedure ComputeExtent; override;
function SelectClick(const within:double; p:CoordPoint):boolean; override;
procedure Reverse; override;
function SetFractal(state: FractalState): boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
end;
BitmapPrimitive = class(DrawPrimitive)
private
image:TBitmap;
corners:CoordRect;
public
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
Procedure ClearThis(Deallocate: Boolean); Override;
constructor CreateBlank;
constructor Create(const start:TBitmap; InitialRect:CoordRect);
procedure Draw(View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
function MoveHandle(const View:ViewPoint; var mode:HandleMode; origx,origy,dx,dy:Coord):boolean; override;
procedure Move(dx,dy:Coord); override;
procedure ComputeExtent; override;
function SelectClick(const within:double; p:CoordPoint):boolean; override;
function SetFillColor(color:TColor):boolean; override;
function GetFillColor:TColor; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
end;
HyperlinkPrimitive = class(DrawPrimitive)
private
x1,y1:Coord;
flags:THyperlinkFlags;
text:string;
public
function Copy:DrawPrimitive; override;
Procedure CopyFromBase(AliasOnly: Boolean); Override;
constructor CreateBlank;
constructor Create(const x,y:Coord; str:string; flag:THyperlinkFlags);
procedure Draw(View:ViewPoint); override;
function ApplyMatrix(var mat:Matrix):boolean; override;
procedure Move(dx,dy:Coord); override;
procedure ComputeExtent; override;
function SelectClick(const within:double; p:CoordPoint):boolean; override;
function GetTextAttrib:TextAttrib; override;
function SetTextAttrib(const View:ViewPoint; const attrib:TextAttrib):boolean; override;
function FindHyperlink(const View:ViewPoint; x,y:Coord; var hypertext:string; var hyperflags:THyperlinkFlags):boolean; override;
function GetId:char; override;
procedure DoRead(stream:TStream; version:integer; Full,UseAliasInfo: Boolean); override;
procedure Write(stream:TStream; Full,UseAliasInfo: Boolean; AddX: Coord = 0; AddY: Coord = 0); override;
Procedure ReadFromDOMElement(E: TDOMElement; Version: Integer); Override;
Function GetAsDOMElement(D: TDOMDocument; Undo: Boolean): TDOMElement; Override;
Function IsSimilarTo(D: DrawPrimitive): Boolean; Override;
Function GetAdjustedX1: Coord;
Function GetAdjustedY1: Coord;
end;
procedure StartNewHandleDraw;
procedure ReadOverlayColors;
function CombineObjects(o1,o2:DrawPrimitive):DrawPrimitive;
function ConvertObject(obj:DrawPrimitive; newtype:char):DrawPrimitive;
function AdjustToPrinterPage(ViewRect:CoordRect):CoordRect;
var OverlayMainColor:array [0..29] of TColor;
OverlayFillColor:array [0..29] of TColor;
HyperlinkBullet:TBitmap;
implementation
uses MapObject,Main,TextSpecialties,SettingsDialog, Printers, ColorButton, StreamUtil, LocalizedStrings, Bezier;
var LastHandleX,LastHandleY:Coord;
FillPalette:HPalette;
Function XMLIDFromCharID(C: Char): String;
Begin
Case C Of
'L','l': Result := 'LINE';
'C','c': Result := 'CURVE';
'P','p': Result := 'POLYLINE';
'K','k': Result := 'POLYCURVE';
'S': Result := 'SYMBOL';
'T': Result := 'TEXT';
't': Result := 'TEXTCURVE';
'G': Result := 'GROUP';
'B': Result := 'BITMAP';
'H': Result := 'HYPERLINK';
Else
Result := 'UNKNOWN';
End; // Case
End; // XMLIDFromCharID
Function CharIDFromXMLID(S: String; Fractal: Boolean): Char;
Var C: Char;
Begin
If S = 'LINE' Then C := 'L'
Else If S = 'CURVE' Then C := 'C'
Else If S = 'POLYLINE' Then C := 'P'
Else If S = 'POLYCURVE' Then C := 'K'
Else If S = 'SYMBOL' Then C := 'S'
Else If S = 'TEXT' Then C := 'T'
Else If S = 'TEXTCURVE' Then C := 't'
Else If S = 'GROUP' Then C := 'G'
Else If S = 'BITMAP' Then C := 'B'
Else If S = 'HYPERLINK' Then C := 'H'
Else C := #0;
If Fractal Then
Begin
Case C Of
'L': C := 'l';
'C': C := 'c';
'P': C := 'p';
'K': C := 'k';
End; // Case
End;
Result := C;
End; // CharIDFromXMLID
procedure ReadOverlayColors;
var i:integer;
b:TBitmap;
begin
b:=TBitmap.Create;
for i:=0 to 29 do begin
MainForm.OverlayColors.GetBitmap(i,b);
OverlayMainColor[i]:=b.Canvas.Pixels[0,0];
OverlayFillColor[i]:=b.Canvas.Pixels[1,1];
end;
b.Free;
end;
{ ------------------------------------------------------------ }
function AdjustToPrinterPage(ViewRect:CoordRect):CoordRect;
var vr:CoordRect;
vw,vh:Coord;
printerpix,screenpix,adjust:Double;
begin
vr:=ViewRect;
vw:=vr.Right-vr.Left;
vh:=vr.Bottom-vr.Top;
screenpix:=vw/vh;
printerpix:=Printer.PageWidth/Printer.PageHeight;
if (round(screenpix*100000)<>round(printerpix*100000)) then begin
if (screenpix<printerpix) then begin {Coordinate Width < Screen Width }
adjust:=0.5*vw*printerpix/screenpix;
vr.left := (ViewRect.left+ViewRect.right)/2 - adjust;
vr.right:= (ViewRect.left+ViewRect.right)/2 + adjust;
end
else if (screenpix>printerpix) then begin {Coordinate Height < Screen Height }
adjust:=0.5*vh*screenpix/printerpix;
vr.top := (ViewRect.top+ViewRect.bottom)/2 - adjust;
vr.bottom:= (ViewRect.top+ViewRect.bottom)/2 + adjust;
end;
end;
Result:=vr;
end;
constructor ViewPoint.Create;
begin
inherited Create;
Name:='';
VisibleOverlays:=[];
ActiveOverlays:=[];
Canvas:=nil;
Grid:=GridObject.Create;
QuickDraw:=QuickDraw_None;
OffScreenFullDetail:=false;
end;
constructor ViewPoint.Create(rect:CoordRect; cw,ch:integer);
begin
inherited Create;
ClientWidth:=cw;
ClientHeight:=ch;
Area:=rect;
Name:='';
VisibleOverlays:=[];
ActiveOverlays:=[];
Canvas:=nil;
Grid:=GridObject.Create;
QuickDraw:=QuickDraw_None;
end;
constructor ViewPoint.Create(rect:CoordRect; cw,ch:integer; oldgrid:GridObject);
begin
inherited Create;
ClientWidth:=cw;
ClientHeight:=ch;
Area:=rect;
Name:='';
VisibleOverlays:=[];
ActiveOverlays:=[];
Canvas:=nil;
Grid:=GridObject.Create(oldgrid);
QuickDraw:=QuickDraw_None;
end;
constructor ViewPoint.Create(view:ViewPoint; useprinter:boolean);
begin
inherited Create;
Name:=view.Name;
if useprinter then begin
Area:=AdjustToPrinterPage(view.Area);
ClientWidth:=Printer.PageWidth;
ClientHeight:=Printer.PageHeight;
Canvas := Printer.Canvas;
end
else begin
Area:=view.Area;
ClientWidth:=view.ClientWidth;
ClientHeight:=view.ClientHeight;
Canvas:=view.Canvas;
end;
VisibleOverlays:=view.VisibleOverlays;
ActiveOverlays:=view.ActiveOverlays;
SetCoordinateSize(ClientWidth, ClientHeight, false);
Grid:=GridObject.Create(view.Grid);
QuickDraw:=QuickDraw_None;
end;
destructor ViewPoint.Destroy;
begin
Grid.Free;
inherited Destroy;
end;
Function ViewPoint.GetAsDOMElement(D: TDOMDocument): TDOMElement;
Var
E : TDOMElement;
I : Integer;
S : String;
Begin
E := D.createElement('VIEWPOINT');
E.appendChild(NewStringProperty(D,'NAME',MimeEncodeString(Name)));
E.appendChild(NewIntegerProperty(D,'CLIENTWIDTH',ClientWidth));
E.appendChild(NewIntegerProperty(D,'CLIENTHEIGHT',ClientHeight));
E.appendChild(NewCoordRectProperty(D,'AREA',Area));
S := '';
For I := 0 To 255 Do
Begin
If I In VisibleOverlays Then
Begin
If S <> '' Then S := S + ',';
S := S + IntToStr(I);
End;
End; // For I
E.appendChild(NewStringProperty(D,'VISIBLE_OVERLAYS',S));
S := '';
For I := 0 To 255 Do
Begin
If I In ActiveOverlays Then
Begin
If S <> '' Then S := S + ',';
S := S + IntToStr(I);
End;
End; // For I
E.appendChild(NewStringProperty(D,'ACTIVE_OVERLAYS',S));
E.appendChild(Grid.GetAsDOMElement(D));
Result := E;
End; // ViewPoint.GetAsDOMElement
Procedure ViewPoint.LoadFromDOMElement(E: TDOMElement);
Var
S : String;
St : String;
I,J : Integer;
E1 : TDOMElement;
Begin
Name := MimeDecodeString(Trim(GetStringProperty(E,'NAME')));
ClientWidth := GetIntegerProperty(E,'CLIENTWIDTH');
ClientHeight := GetIntegerProperty(E,'CLIENTHEIGHT');
Area := GetCoordRectProperty(E,'AREA');
S := Trim(GetStringProperty(E,'VISIBLE_OVERLAYS'));
VisibleOverlays := [];
While S <> '' Do
Begin
I := Pos(',',S);
If I <> 0 Then
Begin
St := Trim(Copy(S,1,I - 1));
S := Trim(Copy(S,I + 1,Length(S)));
End
Else
Begin
St := S;
S := '';
End;
Val(St,I,J);
If (J = 0) And (I >= 0) And (I < 256) Then VisibleOverlays := VisibleOverlays + [I];
End; // While
S := Trim(GetStringProperty(E,'ACTIVE_OVERLAYS'));
ActiveOverlays := [];
While S <> '' Do
Begin
I := Pos(',',S);
If I <> 0 Then
Begin
St := Trim(Copy(S,1,I - 1));
S := Trim(Copy(S,I + 1,Length(S)));