-
Notifications
You must be signed in to change notification settings - Fork 22
/
cu_catalog.pas
6637 lines (6376 loc) · 177 KB
/
cu_catalog.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
unit cu_catalog;
{
Copyright (C) 2002 Patrick Chevalley
http://www.ap-i.net
pch@ap-i.net
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
}
{
Catalog interface component. Also contain shared resources.
}
{$mode delphi}{$H+}
interface
uses
bscunit, dscat, findunit, gcatunit, gcmunit, gcvunit, gpnunit, gsccompact,
gscfits, gscunit, lbnunit, microcatunit, oclunit, pgcunit, vocat,
sacunit, skylibcat, skyunit, ticunit, tyc2unit, tycunit, usnoaunit,
usnobunit, wdsunit, u_290, gaiaunit, cu_healpix,
rc3unit, BGRABitmap, BGRABitmapTypes, Graphics,
u_translation, u_constant, u_util, u_projection,
Controls, SysUtils, Classes, Math, Dialogs, Forms;
type
Tcatalog = class(TComponent)
private
{ Private declarations }
LockCat: boolean;
NumCat, CurCat, CurGCat, VerGCat, CurrentUserObj, DSLcolor, MessierStrPos: integer;
GcatFilter, DSLForceColor, PgcLeda, GpnNew: boolean;
EmptyRec: GCatRec;
FFindId: string;
FFindRecOK: boolean;
FFindRec: GCatrec;
Gaiawin: boolean;
Gaiara1,Gaiara2,Gaiade1,Gaiade2: double;
protected
{ Protected declarations }
function InitRec(cat: integer): boolean;
function OpenStarCat: boolean;
function CloseStarCat: boolean;
function NewGCat: boolean;
function GetVOCatS(var rec: GcatRec; filter: boolean = True): boolean;
function GetVOCatN(var rec: GcatRec; filter: boolean = True): boolean;
function GetUObjN(var rec: GcatRec): boolean;
function GetGCatS(var rec: GcatRec): boolean;
function GetGCatV(var rec: GcatRec): boolean;
function GetGCatD(var rec: GcatRec): boolean;
function GetGCatN(var rec: GcatRec): boolean;
function GetGCatL(var rec: GcatRec): boolean;
procedure FindNGCat(id: shortstring; var ar, de: double;
var ok: boolean; ctype: integer = -1);
function GetBSC(var rec: GcatRec): boolean;
function GetSky2000(var rec: GcatRec): boolean;
function GetTYC(var rec: GcatRec): boolean;
procedure FormatTYC2(lin: TY2rec; var rec: GcatRec);
function GetTYC2(var rec: GcatRec): boolean;
procedure FindTYC2(id: string; var ra, Dec: double; var ok: boolean);
function GetTIC(var rec: GcatRec): boolean;
function GetGSCF(var rec: GcatRec): boolean;
function GetGSCC(var rec: GcatRec): boolean;
function GetGSC(var rec: GcatRec): boolean;
function GetUSNOA(var rec: GcatRec): boolean;
function GetUSNOB(var rec: GcatRec): boolean;
function GetMCT(var rec: GcatRec): boolean;
function GetDSbase(var rec: GcatRec): boolean;
function GetDSTyc(var rec: GcatRec): boolean;
function GetDSGsc(var rec: GcatRec): boolean;
function OpenVarStarCat: boolean;
function CloseVarStarCat: boolean;
function GetGCVS(var rec: GcatRec): boolean;
procedure FormatGCVS(lin: GCVrec; var rec: GcatRec);
procedure FindGCVS(id: string; var ra, Dec: double; var ok: boolean);
function OpenDblStarCat: boolean;
function CloseDblStarCat: boolean;
function GetWDS(var rec: GcatRec): boolean;
procedure FormatWDS(lin: WDSrec; var rec: GcatRec);
procedure FindWDS(id: string; var ra, Dec: double; var ok: boolean);
procedure CheckMessierColumn;
function OpenNebCat: boolean;
function CloseNebCat: boolean;
function GetSAC(var rec: GcatRec): boolean;
procedure FormatSAC(lin: SACrec; var rec: GcatRec);
procedure FindSAC(id: string; var ra, Dec: double; var ok: boolean);
function IsNGCpath(path: string): boolean;
function OpenNGC: boolean;
procedure OpenNGCPos(ar1, ar2, de1, de2: double; var ok: boolean);
function CloseNGC: boolean;
procedure FindNGC(id: shortstring; var ar, de: double; var ok: boolean);
function GetNGC(var rec: GcatRec): boolean;
function IsSH2path(path: string): boolean;
function OpenSH2: boolean;
procedure OpenSH2Pos(ar1, ar2, de1, de2: double; var ok: boolean);
function CloseSH2: boolean;
procedure FindSH2(id: shortstring; var ar, de: double; var ok: boolean);
function GetSH2(var rec: GcatRec): boolean;
function IsDRKpath(path: string): boolean;
function OpenDRK: boolean;
procedure OpenDRKPos(ar1, ar2, de1, de2: double; var ok: boolean);
function CloseDRK: boolean;
procedure FindDRK(id: shortstring; var ar, de: double; var ok: boolean);
function GetDRK(var rec: GcatRec): boolean;
function GetLBN(var rec: GcatRec): boolean;
procedure FormatLBN(lin: LBNrec; var rec: GcatRec);
procedure FindLBN(id : string ;var ar,de:double; var ok:boolean);
function GetRC3(var rec: GcatRec): boolean;
procedure FormatPGC(lin: PGCrec; var rec: GcatRec);
function IsPGCpath(path: string): boolean;
function OpenPGC: boolean;
procedure OpenPGCPos(ar1, ar2, de1, de2: double; var ok: boolean);
function ClosePGC: boolean;
procedure FindPGC(id: shortstring; var ar, de: double; var ok: boolean);
function GetPGC(var rec: GcatRec): boolean;
function GetOldPGC(var rec: GcatRec): boolean;
procedure FindOldPGC(id: integer; var ra, Dec: double; var ok: boolean);
function GetOCL(var rec: GcatRec): boolean;
function GetGCM(var rec: GcatRec): boolean;
function IsGPNpath(path: string): boolean;
function OpenGPN: boolean;
procedure OpenGPNPos(ar1, ar2, de1, de2: double; var ok: boolean);
function CloseGPN: boolean;
procedure FindGPN(id: shortstring; var ar, de: double; var ok: boolean);
function GetGPN(var rec: GcatRec): boolean;
function GetGPNold(var rec: GcatRec): boolean;
function OpenLinCat: boolean;
function CloseLinCat: boolean;
procedure FormatGCatS(var rec: GcatRec);
procedure FormatGCatN(var rec: GcatRec);
Procedure Open290(ar1,ar2,de1,de2: double ; var ok : boolean);
Procedure Open290win(var ok : boolean);
function Is290Path(path : string) : Boolean;
Procedure Close290;
function Get290(var rec: GcatRec): boolean;
function OpenGaia: boolean;
procedure OpenGaiaPos(ar1, ar2, de1, de2: double; var ok: boolean);
function NextGaiaLevel: boolean;
function NextGaiaLevelPos(ar1, ar2, de1, de2: double): boolean;
function GetGaia(var rec: GcatRec): boolean;
function GaiaBRtoBV(br:double):double;
function GaiaBRtoBV_DR2(br:double):double;
function GaiaBRtoBV_EDR3(br:double):double;
function GaiaGtoV(g,br:double):double;
function GaiaGtoV_DR2(g,br:double):double;
function GaiaGtoV_EDR3(g,br:double):double;
procedure FormatGaia(var rec: GcatRec);
function FindGaia(id: string; var ar, de: double): boolean;
public
{ Public declarations }
cfgcat: Tconf_catalog;
cfgshr: Tconf_shared;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function OpenCat(c: Tconf_skychart): boolean;
function CloseCat: boolean;
function OpenStar: boolean;
function CloseStar: boolean;
function ReadStar(var rec: GcatRec): boolean;
function OpenVarStar: boolean;
function CloseVarStar: boolean;
function ReadVarStar(var rec: GcatRec): boolean;
function OpenDblStar: boolean;
function CloseDblStar: boolean;
function ReadDblStar(var rec: GcatRec): boolean;
function OpenNeb: boolean;
function CloseNeb: boolean;
function ReadNeb(var rec: GcatRec): boolean;
function OpenLin: boolean;
function CloseLin: boolean;
function ReadLin(var rec: GcatRec): boolean;
function OpenMilkyWay(fill: boolean): boolean;
function CloseMilkyWay: boolean;
function ReadMilkyWay(var rec: GcatRec): boolean;
function OpenDSL(surface, forcecolor: boolean; col: integer): boolean;
function CloseDSL: boolean;
function ReadDSL(var rec: GcatRec): boolean;
Function IsDefaultStarspath(path : string) : Boolean;
function OpenDefaultStars: boolean;
procedure OpenDefaultStarsPos(ar1, ar2, de1, de2: double; var ok: boolean);
function CloseDefaultStars: boolean;
function GetDefaultStars(var rec: GcatRec): boolean;
procedure FindDefaultStars(id: shortstring; var ar, de: double;
var ok: boolean; ctype: integer = -1);
function FindNum(cat: integer; id: string; var ra, Dec: double): boolean;
function SearchNebulae(Num: string; var ar1, de1: double): boolean;
function SearchStar(Num: string; var ar1, de1: double): boolean;
function SearchStarNameExact(Num: string; var ar1, de1: double): boolean;
function SearchStarNameGeneric(Num: string; var ar1, de1: double): boolean;
function SearchDblStar(Num: string; var ar1, de1: double): boolean;
function SearchVarStar(Num: string; var ar1, de1: double): boolean;
function SearchVarAlias(Num: string; out buf:string): boolean;
function SearchLines(Num: string; var ar1, de1: double): boolean;
function SearchConstellation(Num: string; var ar1, de1: double): boolean;
function SearchConstAbrev(Num: string; var ar1, de1: double): boolean;
function FindAtPos(cat: integer; x1, y1, x2, y2: double;
nextobj, truncate, searchcenter: boolean; cfgsc: Tconf_skychart; var rec: Gcatrec): boolean;
function FindInWin(cat: integer; nextobj: boolean; cfgsc: Tconf_skychart; var rec: Gcatrec): boolean;
function FindObj(x1, y1, x2, y2: double; searchcenter: boolean; cfgsc: Tconf_skychart;
var rec: Gcatrec; ftype: integer = ftAll): boolean;
procedure GetAltName(rec: GCatrec; var txt: string);
function CheckPath(cat: integer; catpath: string): boolean;
function GetInfo(path, shortname: string; var magmax: single;
var v: integer; var version, longname: string): boolean;
function GetMaxField(path, cat: string): string;
function GetCatType(path, cat: string): integer;
function GetNebColorSet(path, cat: string): boolean;
function GetCatURL(path, cat: string): string;
function GetCatTxtFile(path, cat: string): string;
function GetVOstarmag: double;
procedure LoadVariableAlias(fpath: string);
procedure LoadConstellation(fpath, lang: string);
procedure LoadConstL(fname: string);
procedure LoadConstB(fname: string);
procedure LoadMilkywaydot(fname: string);
procedure LoadStarName(fpath, lang: string);
function LongLabelGreek(txt: string): string;
function GenitiveConst(txt: string): string;
function LongLabelConst(txt: string): string;
function LongLabel(txt: string): string;
function LongLabelObj(txt: string): string;
function Get290MagMax: double;
function GetGaiaMagMax: double;
procedure ClearSearch;
procedure CleanCache;
procedure AdjustStarForDistance(var rec:GCatrec; distfact:double);
property FindId: string read FFindId;
property FindRecOK: boolean read FFindRecOK;
property FindRec: GCatrec read FFindRec write FFindRec;
published
{ Published declarations }
end;
implementation
// compute nebula radius
function GetRadius(var rec: Gcatrec): double;
var
nebunit: double;
begin
Result := 0;
if rec.neb.valid[vnNebunit] then
nebunit := rec.neb.nebunit
else
nebunit := rec.options.Units;
if nebunit <> 0 then
begin
Result := minarc * rec.neb.dim1 * 60 / 2 / nebunit;
if Result = 0 then
Result := minarc * rec.neb.dim2 * 60 / 2 / nebunit;
end;
end;
constructor Tcatalog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
cfgcat := Tconf_catalog.Create;
cfgshr := Tconf_shared.Create;
lockcat := False;
Gaiawin := true;
end;
destructor Tcatalog.Destroy;
begin
gcatunit.CleanCache;
cfgcat.Free;
cfgshr.Free;
try
inherited Destroy;
except
writetrace('error destroy ' + Name);
end;
end;
procedure Tcatalog.ClearSearch;
begin
FFindRecOK := False;
FFindId := '';
end;
procedure Tcatalog.CleanCache;
begin
gcatunit.CleanCache;
end;
function Tcatalog.OpenCat(c: Tconf_skychart): boolean;
var
ac, dc, rac, ddc: double;
begin
// get a lock before to do anything, libcatalog is NOT thread safe.
while lockcat do
begin
sleep(10);
application.ProcessMessages;
end;
lockcat := True;
case c.ProjPole of
Gal:
begin
ac := rad2deg * c.lcentre;
dc := rad2deg * c.bcentre;
end;
Ecl:
begin
ac := rad2deg * c.lecentre;
dc := rad2deg * c.becentre;
end;
else
begin
ac := rad2deg * c.acentre;
dc := rad2deg * c.hcentre;
end;
end;
rac := c.racentre;
ddc := c.decentre;
if c.ApparentPos then
mean_equatorial(rac, ddc, c, True, True);
InitCatWin(c.axglb, c.ayglb, c.bxglb / rad2deg, c.byglb / rad2deg, c.sintheta,
c.costheta, rad2deg * rac / 15, rad2deg * ddc, ac, dc, c.CurJDUT, c.JDChart,
rad2deg * c.CurST / 15, c.ObsLatitude, c.ProjPole, c.xshift, c.yshift, c.xmin,
c.xmax, c.ymin, c.ymax, c.projtype, northpole2000inmap(c), southpole2000inmap(
c), c.ProjEquatorCentered, c.haicx, c.haicy);
skylibcat.fov := c.fov*rad2deg;
Result := True;
end;
function Tcatalog.CloseCat: boolean;
begin
lockcat := False;
CloseGCat;
Result := True;
end;
{ Stars }
function Tcatalog.OpenStar: boolean;
begin
numcat := MaxStarCatalog;
curcat := BaseStar + MaxStarCatalog;
while true do begin
while (curcat > (BaseStar)) and (not cfgcat.starcaton[curcat - BaseStar]) do
Dec(curcat);
if (curcat <= BaseStar) then
Result := False
else begin
Result := OpenStarCat;
if not Result then begin
Dec(curcat); // try next catalog
continue;
end;
end;
break;
end;
end;
function Tcatalog.CloseStar: boolean;
begin
Result := CloseStarCat;
curcat := BaseStar;
end;
function Tcatalog.ReadStar(var rec: GcatRec): boolean;
begin
Result := False;
case curcat of
DefStar: Result := GetDefaultStars(rec);
sky2000: Result := GetSky2000(rec);
tyc: Result := GetTYC(rec);
tyc2: Result := GetTYC2(rec);
tic: Result := GetTIC(rec);
gscf: Result := GetGSCF(rec);
gscc: Result := GetGSCC(rec);
gsc: Result := GetGSC(rec);
usnoa: Result := GetUSNOA(rec);
usnob: Result := GetUSNOB(rec);
hn290: Result := Get290(rec);
gaia: Result := GetGaia(rec);
microcat: Result := GetMCT(rec);
dsbase: Result := GetDSbase(rec);
dstyc: Result := GetDSTyc(rec);
dsgsc: Result := GetDSGsc(rec);
gcstar:
begin
Result := GetGcatS(rec);
if not Result then
begin
Result := NewGcat;
if Result then
begin
OpenGCatWin(Result);
Result := ReadStar(rec);
end;
end;
end;
vostar:
begin
Result := GetVOcatS(rec);
end;
bsc: Result := GetBSC(rec);
end;
if (not Result) and (curcat > (BaseStar+1)) then
begin
repeat
CloseStarCat;
Dec(curcat);
while (curcat > (BaseStar)) and (not cfgcat.starcaton[curcat - BaseStar]) do
Dec(curcat);
Result := False;
if (curcat <= BaseStar) then
break
else
begin
Result := OpenStarCat;
if Result then
Result := ReadStar(rec)
else
cfgcat.starcaton[curcat - BaseStar] := False;
end;
until Result;
end;
end;
function Tcatalog.OpenStarCat: boolean;
var
nty2cat, nmctcat: integer;
begin
if cfgshr.StarFilter and (cfgcat.StarmagMax <= 11) then
begin
nty2cat := 1;
nmctcat := 1;
end
else
begin
nty2cat := 2;
nmctcat := 3;
end;
InitRec(curcat);
case curcat of
DefStar: Result := OpenDefaultStars;
sky2000:
begin
SetSkyPath(cfgcat.starcatpath[sky2000 - BaseStar]);
OpenSkywin(Result);
end;
tyc:
begin
SetTycPath(cfgcat.starcatpath[tyc - BaseStar]);
OpenTYCwin(Result);
end;
tyc2:
begin
SetTy2Path(cfgcat.starcatpath[tyc2 - BaseStar]);
OpenTY2win(nty2cat, Result);
end;
tic:
begin
SetTicPath(cfgcat.starcatpath[tic - BaseStar]);
OpenTICwin(Result);
end;
gscf:
begin
SetGscfPath(cfgcat.starcatpath[gscf - BaseStar]);
OpenGSCFwin(Result);
end;
gscc:
begin
SetGsccPath(cfgcat.starcatpath[gscc - BaseStar]);
OpenGSCCwin(Result);
end;
gsc:
begin
SetGscPath(cfgcat.starcatpath[gsc - BaseStar]);
OpenGSCwin(Result);
end;
usnoa:
begin
SetUSNOAPath(cfgcat.starcatpath[usnoa - BaseStar]);
OpenUSNOAwin(Result);
end;
usnob:
begin
SetUSNOBPath(cfgcat.starcatpath[usnob - BaseStar]);
OpenUSNOBwin(Result);
end;
hn290:
begin
Open290win(Result);
end;
gaia:
begin
Result:=OpenGaia;
end;
microcat:
begin
SetMCTPath(cfgcat.starcatpath[microcat - BaseStar]);
OpenMCTwin(nmctcat, Result);
end;
dsbase:
begin
SetDSPath(cfgcat.starcatpath[dsbase - BaseStar], cfgcat.starcatpath[dstyc - BaseStar],
cfgcat.starcatpath[dsgsc - BaseStar]);
OpenDSbasewin(Result);
end;
dstyc:
begin
SetDSPath(cfgcat.starcatpath[dsbase - BaseStar], cfgcat.starcatpath[dstyc - BaseStar],
cfgcat.starcatpath[dsgsc - BaseStar]);
OpenDStycwin(Result);
end;
dsgsc:
begin
SetDSPath(cfgcat.starcatpath[dsbase - BaseStar], cfgcat.starcatpath[dstyc - BaseStar],
cfgcat.starcatpath[dsgsc - BaseStar]);
OpenDSgscwin(Result);
end;
gcstar:
begin
VerGCat := rtStar;
CurGCat := 0;
Result := False;
while NewGCat do
begin
OpenGCatWin(Result);
if Result then
break;
end;
end;
vostar:
begin
VOobject := 'star';
SetVOCatpath(slash(VODir));
OpenVOCatwin(Result);
end;
bsc:
begin
SetBscPath(cfgcat.starcatpath[bsc - BaseStar]);
OpenBSCwin(Result);
end;
else
Result := False;
end;
end;
function Tcatalog.CloseStarCat: boolean;
begin
Result := True;
case curcat of
DefStar: CloseDefaultStars;
sky2000: CloseSky;
tyc: CloseTYC;
tyc2: CloseTY2;
tic: CloseTIC;
gscf: CloseGSCF;
gscc: CloseGSCC;
gsc: CloseGSC;
usnoa: CloseUSNOA;
usnob: CloseUSNOB;
hn290: Close290;
gaia: CloseGaia;
microcat: CloseMCT;
dsbase: CloseDSbase;
dstyc: CloseDStyc;
dsgsc: CloseDSgsc;
gcstar: CloseGcat;
vostar: CloseVOCat;
bsc: CloseBSC;
else
Result := False;
end;
end;
{ Variables Stars }
function Tcatalog.OpenVarStar: boolean;
begin
numcat := MaxVarStarCatalog;
curcat := BaseVar + 1;
while ((curcat - BaseVar) <= numcat) and (not cfgcat.varstarcaton[curcat - BaseVar]) do
Inc(curcat);
if ((curcat - BaseVar) > numcat) then
Result := False
else
Result := OpenVarStarCat;
end;
function Tcatalog.CloseVarStar: boolean;
begin
Result := CloseVarStarCat;
curcat := numcat + BaseVar;
end;
function Tcatalog.ReadVarStar(var rec: GcatRec): boolean;
begin
Result := False;
case curcat of
gcvs: Result := GetGCVS(rec);
gcvar:
begin
Result := GetGcatV(rec);
if not Result then
begin
Result := NewGcat;
if Result then
begin
OpenGCatWin(Result);
Result := ReadVarStar(rec);
end;
end;
end;
end;
if (not Result) and ((curcat - BaseVar) < numcat) then
begin
repeat
CloseVarStarCat;
Inc(curcat);
while ((curcat - BaseVar) <= numcat) and (not cfgcat.varstarcaton[curcat - BaseVar]) do
Inc(curcat);
Result := False;
if ((curcat - BaseVar) > numcat) then
break
else
begin
Result := OpenVarStarCat;
if Result then
Result := ReadVarStar(rec)
else
cfgcat.varstarcaton[curcat - BaseVar] := False;
end;
until Result;
end;
end;
function Tcatalog.OpenVarStarCat: boolean;
begin
InitRec(curcat);
case curcat of
gcvs:
begin
SetGCVPath(cfgcat.varstarcatpath[gcvs - BaseVar]);
OpenGCVwin(Result);
end;
gcvar:
begin
VerGCat := rtVar;
CurGCat := 0;
Result := False;
while NewGCat do
begin
OpenGCatWin(Result);
if Result then
break;
end;
end;
else
Result := False;
end;
end;
function Tcatalog.CloseVarStarCat: boolean;
begin
Result := True;
case curcat of
gcvs: CloseGCV;
gcvar: CloseGcat;
else
Result := False;
end;
end;
{ Doubles Stars }
function Tcatalog.OpenDblStar: boolean;
begin
numcat := MaxDblStarCatalog;
curcat := BaseDbl + 1;
while ((curcat - BaseDbl) <= numcat) and (not cfgcat.dblstarcaton[curcat - BaseDbl]) do
Inc(curcat);
if ((curcat - BaseDbl) > numcat) then
Result := False
else
Result := OpenDblStarCat;
end;
function Tcatalog.CloseDblStar: boolean;
begin
Result := CloseDblStarCat;
curcat := numcat + BaseDbl;
end;
function Tcatalog.ReadDblStar(var rec: GcatRec): boolean;
begin
Result := False;
case curcat of
wds: Result := GetWDS(rec);
gcdbl:
begin
Result := GetGcatD(rec);
if not Result then
begin
Result := NewGcat;
if Result then
begin
OpenGCatWin(Result);
Result := ReadDblStar(rec);
end;
end;
end;
end;
if (not Result) and ((curcat - BaseDbl) < numcat) then
begin
repeat
CloseDblStarCat;
Inc(curcat);
while ((curcat - BaseDbl) <= numcat) and (not cfgcat.dblstarcaton[curcat - BaseDbl]) do
Inc(curcat);
Result := False;
if ((curcat - BaseDbl) > numcat) then
break
else
begin
Result := OpendblStarCat;
if Result then
Result := ReadDblStar(rec)
else
cfgcat.dblstarcaton[curcat - BaseDbl] := False;
end;
until Result;
end;
end;
function Tcatalog.OpenDblStarCat: boolean;
begin
InitRec(curcat);
case curcat of
wds:
begin
SetWDSPath(cfgcat.dblstarcatpath[wds - BaseDbl]);
OpenWDSwin(Result);
end;
gcdbl:
begin
VerGCat := rtDbl;
CurGCat := 0;
Result := False;
while NewGCat do
begin
OpenGCatWin(Result);
if Result then
break;
end;
end;
else
Result := False;
end;
end;
function Tcatalog.CloseDblStarCat: boolean;
begin
Result := True;
case curcat of
wds: CloseWDS;
gcdbl: CloseGcat;
else
Result := False;
end;
end;
{ Nebulae }
function Tcatalog.OpenNeb: boolean;
begin
numcat := MaxNebCatalog;
curcat := BaseNeb + 1;
while ((curcat - BaseNeb) <= numcat) and (not cfgcat.nebcaton[curcat - BaseNeb]) do
Inc(curcat);
if ((curcat - BaseNeb) > numcat) then
Result := False
else
Result := OpenNebCat;
end;
function Tcatalog.CloseNeb: boolean;
begin
Result := CloseNebCat;
curcat := numcat + BaseNeb;
end;
function Tcatalog.ReadNeb(var rec: GcatRec): boolean;
begin
Result := False;
case curcat of
sac: Result := GetSAC(rec);
ngc: Result := GetNGC(rec);
lbn: Result := GetLBN(rec);
sh2: Result := GetSH2(rec);
drk: Result := GetDRK(rec);
rc3: Result := GetRC3(rec);
pgc: Result := GetPGC(rec);
ocl: Result := GetOCL(rec);
gcm: Result := GetGCM(rec);
gpn: Result := GetGPN(rec);
gcneb:
begin
Result := GetGcatN(rec);
if not Result then
begin
Result := NewGcat;
if Result then
begin
OpenGCatWin(Result);
CheckMessierColumn;
Result := ReadNeb(rec);
end;
end;
end;
voneb:
begin
Result := GetVOcatN(rec);
end;
uneb:
begin
Result := GetUObjN(rec);
end;
end;
if (not Result) and ((curcat - BaseNeb) < numcat) then
begin
repeat
CloseNebCat;
Inc(curcat);
while ((curcat - BaseNeb) <= numcat) and (not cfgcat.nebcaton[curcat - BaseNeb]) do
Inc(curcat);
Result := False;
if ((curcat - BaseNeb) > numcat) then
break
else
begin
Result := OpenNebCat;
if Result then
Result := ReadNeb(rec)
else
cfgcat.nebcaton[curcat - BaseNeb] := False;
end;
until Result;
end;
end;
procedure Tcatalog.CheckMessierColumn;
var
i: integer;
trec: GCatrec;
begin
// Messier object ?
MessierStrPos := -1;
GetEmptyRec(trec);
for i := 1 to 10 do
if trec.vstr[i] and trec.options.altname[i] and trec.options.altprefix[i] and
(trim(trec.options.flabel[15 + i]) = 'M') then
begin
MessierStrPos := i;
break;
end;
end;
function Tcatalog.OpenNebCat: boolean;
begin
InitRec(curcat);
MessierStrPos := -1;
case curcat of
sac:
begin
SetSacPath(cfgcat.nebcatpath[sac - BaseNeb]);
OpenSACwin(Result);
end;
ngc: Result := OpenNGC;
lbn:
begin
SetlbnPath(cfgcat.nebcatpath[lbn - BaseNeb]);
Openlbnwin(Result);
end;
sh2: Result := OpenSH2;
drk: Result := OpenDRK;
rc3:
begin
Setrc3Path(cfgcat.nebcatpath[rc3 - BaseNeb]);
Openrc3win(Result);
end;
pgc: Result := OpenPGC;
ocl:
begin
SetoclPath(cfgcat.nebcatpath[ocl - BaseNeb]);
Openoclwin(Result);
end;
gcm:
begin
SetgcmPath(cfgcat.nebcatpath[gcm - BaseNeb]);
Opengcmwin(Result);
end;
gpn: Result := OpenGPN;
gcneb:
begin
VerGCat := rtNeb;
CurGCat := 0;
Result := False;
while NewGCat do
begin
OpenGCatWin(Result);
if Result then
break;
end;
CheckMessierColumn;
end;
voneb:
begin
VOobject := 'dso';
SetVOCatpath(slash(VODir));
OpenVOCatwin(Result);
end;
uneb:
begin
CurrentUserObj := -1;
Result := True;
end;
else
Result := False;
end;
end;
function Tcatalog.CloseNebCat: boolean;
begin
Result := True;
case curcat of
sac: CloseSAC;
ngc: CloseNGC;
lbn: CloseLBN;
sh2: CloseSH2;
drk: CloseDRK;
rc3: CloseRC3;
pgc: ClosePGC;
ocl: CloseOCL;