-
Notifications
You must be signed in to change notification settings - Fork 2
/
GClasses.pas
5740 lines (4775 loc) · 152 KB
/
GClasses.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
//-----------------------------------------------------------------------
// Summary
// TGlobe Component General Classes
//
// Description
// Common classes for TGlobe
//
// Author
// Graham Knight (tglobe@tglobe.com)
//-----------------------------------------------------------------------
{$R-}
{$Q-}
{$I GLOBE5.INC}
unit GClasses;
interface
uses ActiveX, Forms, Windows, Classes, Graphics, Controls, SysUtils, StdCtrls,
Printers, GSysUtils, GXML, Contnrs, GDataLink, GBitmap;
const
TG_DEFAULT_MAXPOINTS = 256 * 1024;
TG_PIXEL_TOLERANCE = 2;
TG_GRATICULE_LONG_STEPS = 180;
TG_GRATICULE_LAT_STEPS = 85;
type
{---------------------------- Forward Class Declarations --------------------}
TGCustomGlobe5 = class;
TGCustomDataReader = class;
TGProjector = class;
TGLayer = class;
TGPresenterStore = class;
TGObjectSource = class;
TGRenderer = class;
IGMapPoint = interface;
TPointArray = array of TPoint;
TGFontName = String;
TGProjectionClass = String;
TGRenderClass = String;
TPointData = record // used by the polygon clipper
Point : TPoint;
Code : integer;
end;
TGPenStyle = (gpsSolid, gpsDash, gpsDot, gpsDashDot, gpsDashDotDot, gpsClear, gpsInsideFrame);
TGBrushStyle = (gbsSolid, gbsClear, gbsHorizontal, gbsVertical, gbsFDiagonal,
gbsBDiagonal, gbsCross, gbsDiagCross,
gbsPattern1, gbsPattern2, gbsPattern3, gbsPattern4, gbsPattern5, gbsPattern6,
gbsPattern7, gbsPattern8, gbsPattern9, gbsPattern10, gbsPattern11, gbsPattern12,
gbsPattern13, gbsPattern14, gbsPattern15, gbsPattern16, gbsPattern17, gbsPattern18,
gbsPattern19, gbsPattern20, gbsPattern21, gbsPattern22, gbsPattern23, gbsPattern24,
gbsPattern25, gbsPattern26, gbsPattern27, gbsPattern28, gbsPattern29, gbsPattern30,
gbsPattern31, gbsPattern32, gbsPattern33, gbsPattern34, gbsPattern35, gbsPattern36,
gbsPattern37, gbsPattern38, gbsPattern39, gbsPattern40, gbsPattern41, gbsPattern42,
gbsPattern43, gbsPattern44, gbsPattern45, gbsPattern46, gbsPattern47, gbsPattern48,
gbsPattern49, gbsPattern50);
TGFontStyle = (gfsBold, gfsItalic, gfsUnderline, gfsStrikeOut, gfsOpaque, gfsHalo);
TGFontStyles = set of TGFontStyle;
TGTitleAlignment = (taNone, taCenter, taLeft, taRight,
taTopLeft, taTop, taTopRight, taBottomLeft, taBottom, taBottomRight);
TGMapObjectFlags = (ofTitle, ofID, ofHeight, of16Bit, ofCompressed,
ofSingle, ofLongCount, ofZoomMinMax, ofClosed, ofGreatCircle, ofMultiRing,
ofUserID);
TGMapObjectFlagSet = set of TGMapObjectFlags;
TGObjectSourceNotification = (osnOpen, osnClose, osnAdd, osnDelete,
osnRedraw, osnSelectedChanged, osnCreate, osnFree);
TGObjectCallback = procedure(objPK : TGPrimaryKey; var bAbort : Boolean ) of object;
TGXAxisChanges = (xaYOrigin, xaCentralParallel, xaNoAction);
TGYAxisChanges = (yaXOrigin, yaCentralMeridian, yaNoAction);
TGProjectionProperty = (ppXRotation, ppYRotation, ppZRotation, ppScaleFactor,
ppXOrigin, ppYOrigin, ppCentralMeridian, ppCentralParallel,
ppFirstParallel, ppSecondParallel, ppSpheroid, ppXAxisChanges,
ppYAxisChanges, ppMaxLatitude, ppMinLatitude, ppMaxLongitude, ppMinLongitude,
ppMaxZoom, ppMinZoom);
IGUnderlyingObject = Interface
['{3B20F42E-9508-46D4-8D51-BD82169F9E1E}']
function GetUnderlyingObject : TPersistent;
end;
IGPresenterEvents = Interface
['{38F15E88-6004-4466-AE1F-5F084A405779}']
procedure OnBeginRender( mapPoint : IGMapPoint );
procedure OnEndRender( mapPoint : IGMapPoint );
procedure OnBeginLayer( aLayer : TGLayer );
procedure OnEndLayer( aLayer : TGLayer );
end;
IGMapPoint = Interface
['{3E168D16-28C0-4348-9F68-0413A088DA75}']
function GetCentroid : TGPointLL;
procedure SetCentroid(const ptLL : TGPointLL);
procedure SetHidden(Value : Boolean);
function GetHidden : Boolean;
procedure SetModified(Value : Boolean);
function GetModified : Boolean;
procedure SetPrimaryKey( Value : TGPrimaryKey );
function GetPrimaryKey : TGPrimaryKey;
procedure SetObjectDataCSL(const Value : String);
function GetObjectDataCSL: String;
procedure SetPresenterID(const Value : integer);
function GetPresenterID : integer;
procedure SetSelected(Value : Boolean);
function GetSelected : Boolean;
function GetObjectMER : TGMER;
procedure SetObjectMER( Value : TGMER );
function GetObjectSource : TGObjectSource;
procedure SetObjectSource( Value : TGObjectSource );
function GetAttribute( index : integer ) : String;
procedure SetAttribute( index : integer; const Value : String );
function GetValue( index : integer ) : Double;
procedure SetValue( index : integer; const Value : Double );
function GetUserID : String;
procedure SetUserID( const Value : String );
function GetDataLink : TGDataLink;
procedure SetDataLink( const Value : TGDataLink );
procedure SetXML(const Value : String);
function GetXML: String;
procedure Assign(Source : IGMapPoint);
function ObjectClassName : String;
function Clone : IGMapPoint;
function Layer : TGLayer;
procedure Delete;
function ObjectSize: integer;
function CachableObject: Boolean;
procedure ReadFromDataLink( aDataLink : TGDataLink );
procedure WriteToDataLink( aDataLink : TGDataLink );
procedure LoadFromXML( Element : TGXML_Element );
procedure SaveToXML( Element : TGXML_Element );
procedure Post;
procedure Edit;
procedure CancelEdit;
procedure Render(Globe : TGCustomGlobe5);
function LLInObject( const ptLL : TGPointLL; iTolerance : integer) : Boolean;
function LLInObjectMER( const ptLL : TGPointLL; iTolerance : integer) : TGMERHitZone;
function IntersectMER( const aMER : TGMER ) : Boolean;
procedure Invalidate;
property Centroid : TGPointLL read GetCentroid write SetCentroid;
property DataLink : TGDataLink read GetDataLink write SetDataLink;
property ObjectMER : TGMER read GetObjectMER write SetObjectMER;
property ObjectSource : TGObjectSource read GetObjectSource write SetObjectSource;
property Attribute[index:integer] : String read GetAttribute write SetAttribute;
property Value[index:integer] : Double read GetValue write SetValue;
property Hidden : Boolean read GetHidden write SetHidden;
property Modified : Boolean read GetModified write SetModified;
property PrimaryKey : TGPrimaryKey read GetPrimaryKey write SetPrimaryKey;
property ObjectDataCSL : String read GetObjectDataCSL write SetObjectDataCSL;
property PresenterID : integer read GetPresenterID write SetPresenterID;
property Selected : Boolean read GetSelected write SetSelected;
property UserID : String read GetUserID write SetUserID;
property XML : String read GetXML write SetXML;
end;
TGComponentClass = class of TGComponent;
TGComponent = class(TGENVPersistent)
protected
FParentGlobe : TGCustomGlobe5;
function GetXML: String;
procedure SetXML(const Value: String);
public
constructor Create( parentGlobe: TGCustomGlobe5 ); virtual;
class function CreateFromXML(parentGlobe: TGCustomGlobe5; Element : TGXML_Element;
defaultClass : TGComponentClass) : TGComponent;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
property ParentGlobe : TGCustomGlobe5 read FParentGlobe;
property XML : String read GetXML write SetXML;
end;
TGAttribute = class(TGENVPersistent)
private
FHashValue : Cardinal;
FRenderer : TGRenderer;
FAttributeHandle : Cardinal;
FModified : Boolean;
FOnChange : TNotifyEvent;
procedure SetModified(const Value: Boolean);
protected
procedure DoChange;
procedure CreateHandle( renderer : TGRenderer ); virtual; abstract;
procedure DestroyHandle( renderer : TGRenderer ); virtual;
property HashValue : Cardinal read FHashValue write FHashValue;
public
constructor Create; virtual;
destructor Destroy; override;
function AttributeHandle( renderer : TGRenderer ): Cardinal; virtual;
function Equals(Attr : TGAttribute) : Boolean; virtual; abstract;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
property Modified : Boolean read FModified write SetModified;
property OnChange : TNotifyEvent read FOnChange write FOnChange;
end;
TGlobeAttributeClass = class of TGAttribute;
TGPen = class(TGAttribute)
private
FPenAltitude : Cardinal;
FColor : TColor;
FStyle : TGPenStyle;
FWidth : integer;
FWidthUnit : TGUnitTypes;
procedure SetColor(Value : TColor);
procedure SetStyle(Value : TGPenStyle);
procedure SetWidth(Value : integer);
procedure SetUnit(Value : TGUnitTypes);
protected
procedure CreateHandle( renderer : TGRenderer ); override;
public
constructor Create; override;
procedure Define(color : TColor; style : TGPenStyle; width : integer;
widthUnit : TGUnitTypes);
procedure Assign(Attr : TPersistent); override;
procedure AssignTo(Attr : TPersistent); override;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
function AttributeHandle( renderer : TGRenderer ): Cardinal; override;
function Clone : TGPen;
function Equals(Attr : TGAttribute) : Boolean; override;
published
property Color : TColor read FColor write SetColor;
property Style : TGPenStyle read FStyle write SetStyle;
property Width : integer read FWidth write SetWidth;
property WidthUnit : TGUnitTypes read FWidthUnit write SetUnit;
end;
TGlobePenClass = class of TGPen;
TGBrush = class(TGAttribute)
private
FColor : TColor;
FStyle : TGBrushStyle;
FBkColor: TColor;
procedure SetColor(Value : TColor);
procedure SetStyle(Value : TGBrushStyle);
procedure SetBkColor(const Value: TColor);
protected
procedure CreateHandle( renderer : TGRenderer ); override;
public
constructor Create; override;
procedure Define(color, bkColor : TColor; style : TGBrushStyle);
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
function AttributeHandle( renderer : TGRenderer ): Cardinal; override;
procedure Assign(Attr : TPersistent); override;
procedure AssignTo(Attr : TPersistent); override;
function Clone : TGBrush;
function Equals(Attr : TGAttribute) : Boolean; override;
published
property BkColor : TColor read FBkColor write SetBkColor;
property Color : TColor read FColor write SetColor;
property Style : TGBrushStyle read FStyle write SetStyle;
end;
TGlobeBrushClass = class of TGBrush;
TGFont = class(TGAttribute)
private
FontAltitude : Cardinal;
FSize : integer;
FSizeUnit : TGUnitTypes;
FColor : TColor;
FAngle : integer;
FStyle : Byte;
FName : TGFontName;
FBkColor: TColor;
FBkAlphaBlend: Byte;
function GetStyle : TGFontStyles;
procedure SetStyle(Value : TGFontStyles);
procedure SetSizeUnit(Value : TGUnitTypes);
procedure SetColor(Value : TColor);
procedure SetAngle(Value : integer);
procedure SetSize(Value : integer);
procedure SetFontName(Value : TGFontName);
procedure SetBkColor(const Value: TColor);
procedure SetBkAlphaBlend(const Value: Byte);
protected
procedure CreateHandle( renderer : TGRenderer ); override;
public
constructor Create; override;
procedure Define(const name : TGFontName; color, bkColor : TColor;
size : integer; sizeUnit : TGUnitTypes; angle : integer; style : TGFontStyles;
bkAlpha : Byte = 255);
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
function AttributeHandle( renderer : TGRenderer ): Cardinal; override;
procedure Assign(Attr : TPersistent); override;
procedure AssignTo(Attr : TPersistent); override;
function Clone : TGFont;
function Equals(Attr : TGAttribute) : Boolean; override;
published
property Angle : integer read FAngle write SetAngle;
property Color : TColor read FColor write SetColor;
property BkColor : TColor read FBkColor write SetBkColor;
property BkAlphaBlend : Byte read FBkAlphaBlend write SetBkAlphaBlend;
property Name : TGFontName read FName write SetFontName;
property Size : integer read FSize write SetSize;
property Style : TGFontStyles read GetStyle write SetStyle;
property SizeUnit : TGUnitTypes read FSizeUnit write SetSizeUnit;
end;
TGlobeFontClass = class of TGFont;
TGPresenter = class(TGComponent)
private
FAlphaBlend: Byte;
FHidden: Boolean;
FName: String;
FNextPresenterID: integer;
FPresenterID: integer;
FTitleColumn: integer;
FTitleFont : TGFont;
FTitleAlignment : TGTitleAlignment;
FTitleOffset : integer;
FTitleOffsetUnits : TGUnitTypes;
FTitleVisible : TGTriState;
FiTitleZoomMin: integer;
FiTitleZoomMax: integer;
FTitleZoomUnits: TGUnitTypes;
FAltitude : Cardinal;
FRenderer: TGRenderer;
FAdjustedAlphaBlend: Byte;
FPresenterEvents: IGPresenterEvents;
function GetRenderer: TGRenderer;
protected
procedure AdjustTolerance( var tolerance : integer ); virtual;
procedure BeginLayerRender( aLayer : TGLayer ); virtual;
procedure EndLayerRender( aLayer : TGLayer ); virtual;
procedure DoBeginRender( mapObj : IGMapPoint );
procedure DoEndRender( mapObj : IGMapPoint );
procedure DoBeginLayer( aLayer : TGLayer );
procedure DoEndLayer( aLayer : TGLayer );
public
constructor Create(parentGlobe: TGCustomGlobe5); override;
destructor Destroy; override;
function LLInObject( ptLL : TGPointLL; mapObj : IGMapPoint; iTolerance : integer) : Boolean; virtual;
procedure Assign(Source : TPersistent); override;
function Clone : TGPresenter; virtual;
function Equals( aPresenter : TGPresenter ): Boolean; virtual;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
procedure RenderLegend( Canvas : TCanvas; rect : TRect ); virtual;
procedure RenderObject( mapObj : IGMapPoint; State : TGRenderStateSet); virtual;
procedure RenderTitle( mapObj : IGMapPoint; State : TGRenderStateSet ); virtual;
function IsTitleVisible : Boolean; virtual;
property AdjustedAlphaBlend : Byte read FAdjustedAlphaBlend;
property Renderer : TGRenderer read GetRenderer write FRenderer;
property PresenterEvents : IGPresenterEvents read FPresenterEvents write FPresenterEvents;
published
property AlphaBlend : Byte read FAlphaBlend write FAlphaBlend;
property Hidden : Boolean read FHidden write FHidden;
property Name : String read FName write FName;
property PresenterID : integer read FPresenterID write FPresenterID;
property NextPresenterID : integer read FNextPresenterID write FNextPresenterID;
property TitleAlignment : TGTitleAlignment read FTitleAlignment write FTitleAlignment;
property TitleColumn : integer read FTitleColumn write FTitleColumn;
property TitleFont : TGFont read FTitleFont write FTitleFont;
property TitleOffset : integer read FTitleOffset write FTitleOffset;
property TitleOffsetUnits : TGUnitTypes read FTitleOffsetUnits write FTitleOffsetUnits;
property TitleZoomMax : Integer read FiTitleZoomMax write FiTitleZoomMax;
property TitleZoomMin : Integer read FiTitleZoomMin write FiTitleZoomMin;
property TitleZoomUnits : TGUnitTypes read FTitleZoomUnits write FTitleZoomUnits;
end;
TGPresenterClass = class of TGPresenter;
TGLayerStore = class(TGComponent)
private
FParentLayer : TGLayer;
FLayers : TObjectList;
function GetCount: integer;
protected
function GetLayer(iIndex : integer) : TGLayer;
public
constructor Create(Globe : TGCustomGlobe5); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function Add(ALayer : TGLayer) : integer;
procedure Remove(ALayer : TGLayer);
procedure Delete(ALayer : TGLayer);
procedure Move(iFrom, iTo : integer);
procedure Clear;
function LayerByID( ID : TGUID ) : TGLayer;
function LayerByName(const sName : String) : TGLayer;
function LayerFromPresenter( aPresenter : TGPresenter ) : TGLayer;
function IndexOf(ALayer : TGLayer) : integer;
function IndexByName(const sName : String) : integer;
function CreateLayerFromXML(Element : TGXML_Element): TGLayer;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
function ObjectAtLL(ptLL : TGPointLL) : IGMapPoint;
function ObjectAtXY(iX, iY : Integer) : IGMapPoint;
function ObjectByTitle(const sTitle : String ) : IGMapPoint;
function ObjectByUserID(const sUserID : String ) : IGMapPoint;
procedure Render( const viewMER : TGMER );
property Count : integer read GetCount;
property Layers[iIndex : Integer] : TGLayer read GetLayer; default;
property ParentLayer : TGLayer read FParentLayer write FParentLayer;
end;
TGPresenterStore = class(TGComponent)
private
FPresenters : TObjectList;
FModified: Boolean;
function GetAsXMLString: String;
procedure SetAsXMLString(const Value: String);
protected
function GetPresenter(iIndex : integer) : TGPresenter;
function GetCount : integer;
procedure AdjustTolerance( var tolerance : integer ); virtual;
public
constructor Create( parentGlobe : TGCustomGlobe5 ); override;
destructor Destroy; override;
procedure Assign(Source : TPersistent); override;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
function Add(aPresenter : TGPresenter) : integer;
procedure AddPresenters( presenterStore : TGPresenterStore );
function ByID(iPresenterID : integer) : TGPresenter;
function ByName( const PresenterName : String) : TGPresenter;
function Contains(aPresenter : TGPresenter) : Boolean;
procedure Delete(aPresenter : TGPresenter);
procedure Clear;
function FindMatch( aPresenter : TGPresenter ) : integer;
property AsXMLString : String read GetAsXMLString write SetAsXMLString;
property Count : integer read GetCount;
property Modified : Boolean read FModified write FModified;
property Presenters[iIndex : integer] : TGPresenter read GetPresenter; default;
end;
TGIterator = class(TGRoot)
private
FObjectSource : TGObjectSource;
FCurrentPK : TGPrimaryKey;
public
constructor Create( objSource : TGObjectSource ); virtual;
function First : IGMapPoint; virtual;
function Next : IGMapPoint; virtual;
function Last : IGMapPoint; virtual;
function Prior : IGMapPoint; virtual;
function Count : integer; virtual;
property ObjectSource : TGObjectSource read FObjectSource;
end;
TGListIterator = class( TGIterator )
private
FPrimaryKeyList : TList;
FPosition : integer;
public
constructor Create( objSource : TGObjectSource ); override;
destructor Destroy; override;
function First : IGMapPoint; override;
function Next : IGMapPoint; override;
function Last : IGMapPoint; override;
function Prior : IGMapPoint; override;
function Count : integer; override;
function Contains( objPK : TGPrimaryKey ) : Boolean; virtual;
procedure AddPrimaryKey( objPK : TGPrimaryKey ); virtual;
property PrimaryKeyList : TList read FPrimaryKeyList;
end;
TGObjectSource = class(TGComponent)
private
FLayer : TGLayer;
FPresenters: TGPresenterStore;
FName: String;
FCullObjectSize: integer;
FMetaData : TStringList;
FUserXML: TGXML_Element;
FSaveDataInXML: Boolean;
protected
FUniqueID : TGUID;
function GetColumnNames: String;
function GetName: String; virtual;
function GetObjectCount : Cardinal; virtual; abstract;
function GetPresenters: TGPresenterStore; virtual;
procedure SetColumnNames(const Value: String);
procedure SetName(const Value: String); virtual;
procedure SetUniqueID( Value : TGUID); virtual;
public
constructor Create( parentGlobe: TGCustomGlobe5 ); override;
destructor Destroy; override;
function Clone : TGObjectSource; virtual;
procedure CopyFrom( objectSource : TGObjectSource ); virtual;
procedure EditObject( mapObject : IGMapPoint ); virtual;
procedure EndEditObject( mapObject : IGMapPoint ); virtual;
procedure Post; virtual;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
procedure LoadDataFromXML(Element : TGXML_Element); virtual;
procedure SaveDataToXML(Element : TGXML_Element); virtual;
function FirstObject : IGMapPoint; virtual;
function NextObject( mapObject : IGMapPoint ) : IGMapPoint; virtual;
function First : TGPrimaryKey; virtual; abstract;
function Next( objPK : TGPrimaryKey ) : TGPrimaryKey; virtual; abstract;
function ByPrimaryKey( objPK : TGPrimaryKey ): IGMapPoint; virtual; abstract;
function NewIterator : TGIterator; overload; virtual;
function NewIterator( aMER : TGMER ) : TGIterator; overload; virtual; abstract;
procedure ForEach( const aMER :TGMER; callback : TGObjectCallback); virtual; abstract;
procedure Clear; virtual;
procedure Delete; virtual; abstract;
procedure Add( obj : IGMapPoint ); virtual;
procedure Remove( obj : IGMapPoint ); virtual; abstract;
function DataMER : TGMER; virtual;
function IsValid : Boolean; virtual;
function IsTemporary : Boolean; virtual; abstract;
function ImageByName( const Image: TGBitmap; var ImageName : TFilename ) : Boolean; virtual; abstract;
function ImportImage( const ImageName : String ) : String; virtual; abstract;
procedure ImportImageStream( const ImageName : String; imageStream : TMemoryStream ); virtual; abstract;
procedure ExportImageStream( const ImageName : String; imageStream : TStream ); virtual; abstract;
procedure ImportData( reader : TGCustomDataReader ); virtual;
property MetaData : TStringList read FMetaData;
property CullObjectSize : integer read FCullObjectSize write FCullObjectSize;
property Layer : TGLayer read FLayer write FLayer;
property Presenters : TGPresenterStore read GetPresenters;
property SaveDataInXML : Boolean read FSaveDataInXML write FSaveDataInXML;
property UserXML : TGXML_Element read FUserXML;
{$IFDEF BCB}
property UniqueID : TGUID read FUniqueID write SetUniqueID;
{$ENDIF}
published
property ColumnNames : String read GetColumnNames write SetColumnNames;
property Name : String read GetName write SetName;
property ObjectCount : Cardinal read GetObjectCount;
{$IFNDEF BCB}
property UniqueID : TGUID read FUniqueID write SetUniqueID;
{$ENDIF}
end;
TGObjectSourceClass = class of TGObjectSource;
TGSelection = class(TGRoot)
public
function First : IGMapPoint; virtual; abstract;
function Next : IGMapPoint; virtual; abstract;
function Last : IGMapPoint; virtual; abstract;
function Prior : IGMapPoint; virtual; abstract;
function Count : integer; virtual; abstract;
function Clear : Boolean; virtual; abstract;
end;
TGGlobeSelection = class( TGSelection )
private
FParentGlobe : TGCustomGlobe5;
FLayerStack : TList;
FPosition : integer;
FStartLayer : Boolean;
procedure BuildLayerStack(aLayer: TGLayer);
public
constructor Create( parentGlobe: TGCustomGlobe5 );
destructor Destroy; override;
function First : IGMapPoint; override;
function Next : IGMapPoint; override;
function Last : IGMapPoint; override;
function Prior : IGMapPoint; override;
function Count : integer; override;
function Clear : Boolean; override;
end;
TGLayerSelection = class( TGSelection )
private
FPosition : integer;
FParentLayer : TGLayer;
FBuckets : array of TList;
FCount : integer;
function Hash( key : TGPrimaryKey ) : integer;
function GetKey(index: integer): TGPrimaryKey;
public
constructor Create( parentLayer : TGLayer );
destructor Destroy; override;
procedure Add( key : TGPrimaryKey );
function Contains( key : TGPrimaryKey ) : Boolean;
procedure Remove( key : TGPrimaryKey );
function First : IGMapPoint; override;
function Next : IGMapPoint; override;
function Last : IGMapPoint; override;
function Prior : IGMapPoint; override;
function Count : integer; override;
function Clear : Boolean; override;
end;
TGLayer = class(TGComponent)
private
FParentLayer : TGLayer;
FLayerStore : TGLayerStore;
FsLayerName : String;
FPresenters : TGPresenterStore;
FPresenterCache : TList;
FCurrentPresenter : TGPresenter;
FSelection: TGLayerSelection;
FbEnabled : Boolean;
FbSelectable : Boolean;
FbShowTitles : Boolean;
FbVisible : Boolean;
FbNoInterrupt : Boolean;
FUpdateCounter : integer;
FRenderObjectCount : integer;
FRenderPass : integer;
FZoomMin : Cardinal;
FZoomMax : Cardinal;
FMinObjectSize: integer;
FZoomUnits : TGUnitTypes;
FModified: Boolean;
FObjectSource: TGObjectSource;
FTitleColumn: integer;
FSurfaceBitmap : TGBitmap;
FSurfaceImageName: TFilename;
FSurfaceAlpha: Byte;
FSurfaceTransparentColor: TColor;
FReRenderLayer: Boolean;
FUserXML: TGXML_Element;
FRenderAllObjects: Boolean;
FAlphaBlend: Byte;
function GetLayerID: TGUID;
procedure SetSurfaceImageName(const Value: TFilename);
function GetTitleColumnName: String;
procedure SetTitleColumnName(const Value: String);
procedure SetAlphaBlend(const Value: Byte);
protected
function GetIndex : integer;
function GetLayerName : String;
function GetObjectSource: TGObjectSource;
function GetProjection : TGProjector;
procedure SetIndex(iIndex : integer);
procedure SetLayerName(const Value: String);
procedure SetLayerBoolean(iIndex : Integer; bValue : Boolean);
procedure SetObjectSource(const Value: TGObjectSource);
procedure SetZoomUnits(Value : TGUnitTypes);
procedure SetTitleColumn(const Value: integer);
procedure SetZoomMax(const Value: Cardinal);
procedure SetZoomMin(const Value: Cardinal);
function IsRenderAborted : Boolean;
function PeriodicUpdate : Boolean;
function MaxTolerance : integer;
procedure RenderObject(objPK : TGPrimaryKey; var bAbort : Boolean );
public
constructor Create(ParentGlobe : TGCustomGlobe5); override;
destructor Destroy; override;
procedure Clear;
procedure Delete;
procedure Post;
procedure BeginUpdate;
procedure EndUpdate;
procedure Assign(Source: TPersistent); override;
function Clone: TGLayer;
function ClearSelected : Boolean;
function SelectObjects( aMER : TGMER; includeSubLayers, firstOnly, state : Boolean ) : integer;
function FindPresenter(iPresenterID : integer) : TGPresenter;
function IsShowing : Boolean;
function IsValid : Boolean;
function LayerMER : TGMER;
function LayerDepth : integer;
function AdjustedAlphaBlend : Byte;
function ObjectAtLL(ptLL : TGPointLL) : IGMapPoint;
function ObjectAtXY(iX, iY : Integer) : IGMapPoint;
function ObjectByTitle(const sTitle : String ) : IGMapPoint;
function ObjectByUserID(const sUserID : String ) : IGMapPoint;
procedure Render( firstPass : Boolean; const viewMER : TGMER ); virtual;
function TitleColumnToIndex( const columnName : String ) : integer;
function TitleColumnToName( index : integer ) : String;
function LoadImage( image : TGBitmap; var imageName : TFilename ) : Boolean;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure SaveToXML(Element : TGXML_Element); override;
property Modified : Boolean read FModified write FModified;
property ParentLayer : TGLayer read FParentLayer;
property Presenters : TGPresenterStore read FPresenters;
property Projector : TGProjector read GetProjection;
property RenderObjectCount : integer read FRenderObjectCount;
property RenderPass : integer read FRenderPass;
property LayerStore : TGLayerStore read FLayerStore;
property LayerID : TGUID read GetLayerID;
property ReRenderLayer : Boolean read FReRenderLayer write FReRenderLayer;
property Selection : TGLayerSelection read FSelection write FSelection;
property UserXML : TGXML_Element read FUserXML;
published
property AlphaBlend : Byte read FAlphaBlend write SetAlphaBlend;
property Enabled : Boolean index 5 read FbEnabled write SetLayerBoolean;
property Index : integer read GetIndex write SetIndex;
property Name : String read GetLayerName write SetLayerName;
property NoInterrupt : Boolean index 4 read FbNoInterrupt write SetLayerBoolean;
property ObjectSource : TGObjectSource read GetObjectSource write SetObjectSource;
property RenderAllObjects : Boolean read FRenderAllObjects write FRenderAllObjects;
property Selectable : Boolean index 0 read FbSelectable write SetLayerBoolean;
property ShowTitles : Boolean index 3 read FbShowTitles write SetLayerBoolean;
property TitleColumn : integer read FTitleColumn write SetTitleColumn;
property TitleColumnName : String read GetTitleColumnName write SetTitleColumnName;
property Visible : Boolean index 1 read FbVisible write SetLayerBoolean;
property ZoomMax : Cardinal read FZoomMax write SetZoomMax;
property ZoomMin : Cardinal read FZoomMin write SetZoomMin;
property ZoomUnits : TGUnitTypes read FZoomUnits write SetZoomUnits;
property SurfaceImageName : TFilename read FSurfaceImageName write SetSurfaceImageName;
property SurfaceAlpha : Byte read FSurfaceAlpha write FSurfaceAlpha;
property SurfaceTransparentColor : TColor read FSurfaceTransparentColor write FSurfaceTransparentColor;
end;
TGLayerClass = class of TGLayer;
TGCustomProjectionModel = class(TGComponent)
public
function PointStoreToXY(Points : TGPointStore; iStart : integer) : Integer; virtual; abstract;
function PointLLToXY(const ptLL : TGPointLL; iIndex : Integer) : Boolean; virtual; abstract;
function LLToXY(iLong, iLat, iIndex : Integer) : Boolean; virtual; abstract;
function LLHToXY(iLong, iLat, iHeight, iIndex : Integer) : Boolean; virtual; abstract;
function XYToLL(iX, iY, iIndex : Integer) : Boolean; virtual; abstract;
function ExtentsLL : TRect; virtual; abstract;
procedure GetPOZ(var POZ : TGPOZ); virtual; abstract;
procedure SetPOZ(const POZ : TGPOZ); virtual; abstract;
function VisibleMER(const MER : TGMER; var State : TGRenderStateSet) : Boolean; virtual; abstract;
procedure PropertyChanged(ProjectionProperty : TGProjectionProperty); virtual; abstract;
procedure PaintSurfaceImage( image : TGBitmap ); virtual; abstract;
procedure PaintSurface; virtual; abstract;
function Clone(projector : TGProjector) : TGCustomProjectionModel; virtual;
procedure Assign(AModel : TPersistent); override;
function IsContinuous : Boolean; virtual; abstract;
end;
TGCustomProjectionModelClass = class of TGCustomProjectionModel;
TGProjector = class(TGComponent)
private
FiXOrigin : Integer;
FiYOrigin : Integer;
FiAltitude : Cardinal;
FXRotation : TGDecimalDegree;
FYRotation : TGDecimalDegree;
FZRotation : TGDecimalDegree;
FMaxLatitude : TGDecimalDegree;
FMinLatitude : TGDecimalDegree;
FMaxLongitude : TGDecimalDegree;
FMinLongitude : TGDecimalDegree;
FMaxZoom : TGDecimalDegree;
FMinZoom : TGDecimalDegree;
FScaleFactor : Extended;
FCentralMeridian : TGDecimalDegree;
FCentralParallel : TGDecimalDegree;
FFirstParallel : TGDecimalDegree;
FSecondParallel : TGDecimalDegree;
FSpheroid : TGSpheroid;
FXAxisChanges : TGXAxisChanges;
FYAxisChanges : TGYAxisChanges;
FProjectionModel : TGCustomProjectionModel;
FUseMinMaxLimits: Boolean;
FFieldOfViewAngle: TGDecimalDegree;
function GetProjectionClass : String;
procedure SetProjectionClass(projectionClassName : String);
function GetGlobeCenterXY : TPoint;
procedure SetGlobeCenterXY(PT : TPoint);
function GetUnitsPerInch : Integer;
procedure SetUnitsPerInch(UPI : Integer);
function GetUnitsPerPixel: Integer;
procedure SetUnitsPerPixel(const Value: Integer);
protected
procedure SetIntegerProp(ProjectionProperty : integer; Value : Integer);
procedure SetFloatProp(ProjectionProperty : integer; Value : TGDecimalDegree);
procedure SetProjectionModel(Value : TGCustomProjectionModel);
procedure SetUseMinMaxLimits(const Value: Boolean);
procedure SetXAxisChanges(Value : TGXAxisChanges);
procedure SetYAxisChanges(Value : TGYAxisChanges);
procedure SetScaleFactor(eSF : Extended);
procedure SetCenterLat(Value : TGDecimalDegree);
procedure SetCenterLong(Value : TGDecimalDegree);
function GetCenterLat : TGDecimalDegree;
function GetCenterLong : TGDecimalDegree;
public
constructor Create(ParentGlobe : TGCustomGlobe5); override;
destructor Destroy; override;
procedure SaveToXML(Element : TGXML_Element); override;
procedure LoadFromXML(Element : TGXML_Element); override;
procedure Assign(Source : TPersistent); override;
function Clone : TGProjector; virtual;
function DeviceXYToLL(iX, iY : Integer; var ptLL : TGPointLL) : Boolean;
function DeviceXYToDD(iX, iY : Integer; var ptDD : TGPointDD) : Boolean;
function LLToDeviceXY(iLong, iLat : Integer; var ptXY : TPoint) : Boolean;
function DDToDeviceXY(Long, Lat : TGDecimalDegree; var ptXY : TPoint) : Boolean;
function PointLLToXY(const ptLL : TGPointLL; var ptXY : TPoint) : Boolean;
function TriangleLLToXY( worldTri : TGTriangleLL; var screenTri : TGTriangle ) : Boolean;
function IsContinuous : Boolean;
function ExtentsLL : TRect;
function PixelTolerance : integer;
procedure AdjustScaleFactor( ptXY : TPoint; delta : Double );
property ProjectionModel : TGCustomProjectionModel read FProjectionModel write SetProjectionModel;
property GUPerInch : Integer read GetUnitsPerInch write SetUnitsPerInch;
property GUPerPixel : Integer read GetUnitsPerPixel write SetUnitsPerPixel;
property CenterXY : TPoint read GetGlobeCenterXY write SetGlobeCenterXY;
property Altitude : Cardinal read FiAltitude;
published
property CentralMeridian : TGDecimalDegree index Ord(ppCentralMeridian)read FCentralMeridian write SetFloatProp;
property CentralParallel : TGDecimalDegree index Ord(ppCentralParallel)read FCentralParallel write SetFloatProp;
property FirstParallel : TGDecimalDegree index Ord(ppFirstParallel)read FFirstParallel write SetFloatProp;
property SecondParallel : TGDecimalDegree index Ord(ppSecondParallel)read FSecondParallel write SetFloatProp;
property CenterLatitude : TGDecimalDegree read GetCenterLat write SetCenterLat;
property CenterLongitude : TGDecimalDegree read GetCenterLong write SetCenterLong;
property FieldOfViewAngle : TGDecimalDegree read FFieldOfViewAngle write FFieldOfViewAngle;
property MaxLatitude : TGDecimalDegree index Ord(ppMaxLatitude)read FMaxLatitude write SetFloatProp;
property MaxLongitude : TGDecimalDegree index Ord(ppMaxLongitude)read FMaxLongitude write SetFloatProp;
property MaxZoom : TGDecimalDegree index Ord(ppMaxZoom)read FMaxZoom write SetFloatProp;
property MinLatitude : TGDecimalDegree index Ord(ppMinLatitude)read FMinLatitude write SetFloatProp;
property MinLongitude : TGDecimalDegree index Ord(ppMinLongitude)read FMinLongitude write SetFloatProp;
property MinZoom : TGDecimalDegree index Ord(ppMinZoom)read FMinZoom write SetFloatProp;
property ProjectionClass : TGProjectionClass read GetProjectionClass write SetProjectionClass;
property ScaleFactor : Extended read FScaleFactor write SetScaleFactor;
property Spheroid : TGSpheroid read FSpheroid write FSpheroid default WGS84;
property UseMinMaxLimits : Boolean read FUseMinMaxLimits write SetUseMinMaxLimits;
property XRotation : TGDecimalDegree index Ord(ppXRotation)read FXRotation write SetFloatProp;
property YRotation : TGDecimalDegree index Ord(ppYRotation)read FYRotation write SetFloatProp;
property ZRotation : TGDecimalDegree index Ord(ppZRotation)read FZRotation write SetFloatProp;
property XOrigin : Integer index Ord(ppXOrigin)read FiXOrigin write SetIntegerProp;
property YOrigin : Integer index Ord(ppYOrigin)read FiYOrigin write SetIntegerProp;
property XAxisChanges : TGXAxisChanges read FXAxisChanges write SetXAxisChanges;
property YAxisChanges : TGYAxisChanges read FYAxisChanges write SetYAxisChanges;
end;
TGlobeProjectionClass = class of TGProjector;
TGRenderer = class(TGComponent)
private
FHeight : integer;
FWidth : integer;
FAltitude : Cardinal;
FPixelsPerInch : integer;
FDoubleBuffer: Boolean;
FMinTextHeight: Integer;
FMaxTextHeight: Integer;
CpStart : TPointData;
CpStartCode: integer;
CpEnd : TPointData;
CpEndCode : integer;
FState : TCanvasState;
FBrush: TGBrush;
FFont: TGFont;
FPen: TGPen;
FSelectedBrush: TGBrush;
FSelectedPen: TGPen;
FAlphaBlend: Byte;
procedure SetHeight( Value : integer );
procedure SetWidth( Value : integer );
function ClipCode( const pt : TPoint ) : integer;
function StartClip: Boolean;
function EndClip( const pt : TPoint ) : integer;
function GetAltitude: Cardinal;
procedure SetPen(const Value: TGPen);
procedure SetBrush(const Value: TGBrush);
procedure SetFont(const Value: TGFont);
procedure BrushChanged(Sender : TObject);
procedure FontChanged(Sender : TObject);
procedure PenChanged(Sender : TObject);
procedure SetSelectedBrush(const Value: TGBrush);
procedure SetSelectedPen(const Value: TGPen);
protected
CpRegion : array [0..3] of TPoint;
FPoints : TPointArray;
FClippedPoints : TPointArray;
FPolyPolyPoints : array of TPointArray;
FDrawPolyClosed: Boolean;
function ClipPoly(iCount : Integer; closed : Boolean; iPenWidth : integer) : Integer;
procedure DrawPolyPoly(const Points : array of TPointArray; closed: Boolean); virtual; abstract;
function GetCanvas: TCanvas; virtual; abstract;
procedure RendererState(ReqState: TCanvasState);
procedure SetDoubleBuffer(const Value: Boolean); virtual;
procedure UpdateClipRect( offset : integer ); virtual;
public
constructor Create(ParentGlobe : TGCustomGlobe5); override;
destructor Destroy; override;