Skip to content

Commit

Permalink
Add button to import a mosaic in the object list
Browse files Browse the repository at this point in the history
  • Loading branch information
pchev committed Jun 19, 2020
1 parent 8c5173a commit 5685ce4
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
17 changes: 17 additions & 0 deletions skychart/pu_obslist.lfm
Expand Up @@ -95,6 +95,15 @@ object f_obslist: Tf_obslist
ParentFont = False
TabOrder = 6
end
object BtnImportMosaic: TButton
Left = 453
Height = 25
Top = 35
Width = 195
Caption = 'Import mosaic file'
OnClick = BtnImportMosaicClick
TabOrder = 7
end
end
object StringGrid1: TStringGrid
Left = 0
Expand Down Expand Up @@ -426,4 +435,12 @@ object f_obslist: Tf_obslist
left = 360
top = 235
end
object OpenDialog1: TOpenDialog
DefaultExt = '.cdcc'
FileName = 'mosaic'
Filter = 'Circle file|*.cdcc|All|*'
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 260
top = 290
end
end
66 changes: 64 additions & 2 deletions skychart/pu_obslist.pas
Expand Up @@ -44,8 +44,10 @@ interface
Tf_obslist = class(TForm)
Button1: TButton;
BtnTour: TButton;
BtnImportMosaic: TButton;
ButtonLoad: TButton;
AllLabels: TCheckBox;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Expand Down Expand Up @@ -83,6 +85,7 @@ Tf_obslist = class(TForm)
TabSheet2: TTabSheet;
procedure AirmassComboChange(Sender: TObject);
procedure AllLabelsChange(Sender: TObject);
procedure BtnImportMosaicClick(Sender: TObject);
procedure BtnTourClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ButtonLoadClick(Sender: TObject);
Expand Down Expand Up @@ -152,6 +155,7 @@ Tf_obslist = class(TForm)
procedure Add(obj: string; ra, de: double; upd:boolean=true);
procedure LoadObsList;
procedure SaveObsList;
procedure ImportMosaic(fn: string);
procedure SelectRow(r: integer);
function FirstObj: boolean;
function LastObj: boolean;
Expand Down Expand Up @@ -197,8 +201,8 @@ procedure Tf_obslist.SetLang;
begin
Caption := rsObservingLis;
StringGrid1.Columns[0].Title.Caption := rsObject;
StringGrid1.Columns[1].Title.Caption := rsRA;
StringGrid1.Columns[2].Title.Caption := rsDEC;
StringGrid1.Columns[1].Title.Caption := rsRA+' J2000';
StringGrid1.Columns[2].Title.Caption := rsDEC+' J2000';
StringGrid1.Columns[3].Title.Caption := rsStart;
StringGrid1.Columns[4].Title.Caption := rsEnd;
StringGrid1.Columns[5].Title.Caption := rsDescription;
Expand Down Expand Up @@ -227,6 +231,7 @@ procedure Tf_obslist.SetLang;
button1.Caption := rshelp;
SetHelp(self, hlpObslist);
AllLabels.Caption := rsAddLabelForE;
BtnImportMosaic.Caption:=rsImportMosaic;
end;

procedure Tf_obslist.Newlist;
Expand Down Expand Up @@ -267,6 +272,52 @@ procedure Tf_obslist.Add(obj: string; ra, de: double; upd:boolean=true);
end;
end;

procedure Tf_obslist.ImportMosaic(fn: string);
var
f: textfile;
buf1, buf2: string;
x,y,eq: double;
begin
try
AssignFile(f, fn);
reset(f);
eq:=cfgsc.CurJDUT;
repeat
ReadLn(f, buf1);
if copy(buf1,1,8)='EQUINOX=' then begin
buf2:=copy(buf1,9,99);
eq:=StrToFloatDef(buf2,eq);
continue;
end;
buf2 := words(buf1, blank, 2, 1);
x := deg2rad * 15 * Str3ToAR(trim(buf2));
if x = 0 then
begin
continue;
end;
buf2 := words(buf1, blank, 3, 1);
y := deg2rad * Str3ToDE(trim(buf2));
if y = 0 then
begin
continue;
end;
Precession(eq,jd2000,x,y);
StringGrid1.RowCount := StringGrid1.RowCount + 1;
StringGrid1.Cells[1, StringGrid1.RowCount - 1] := words(buf1, blank, 1, 1); ;
buf2 := ARpToStr(rad2deg*x/15,0);
StringGrid1.Cells[2, StringGrid1.RowCount - 1] := buf2;
buf2 := DEToStr3(rad2deg*y);
StringGrid1.Cells[3, StringGrid1.RowCount - 1] := buf2;
StringGrid1.Cells[4, StringGrid1.RowCount - 1] := '';
StringGrid1.Cells[5, StringGrid1.RowCount - 1] := '';
StringGrid1.Cells[6, StringGrid1.RowCount - 1] := '';
StringGrid1.Cells[7, StringGrid1.RowCount - 1] := StringGrid1.Cells[1, StringGrid1.RowCount - 1];
until EOF(f);
CloseFile(f);
except
end;
end;

procedure Tf_obslist.LoadObsList;
var
f: textfile;
Expand Down Expand Up @@ -1142,6 +1193,17 @@ procedure Tf_obslist.AllLabelsChange(Sender: TObject);
FObjLabelChange(self);
end;

procedure Tf_obslist.BtnImportMosaicClick(Sender: TObject);
var fn: string;
begin
if OpenDialog1.InitialDir = '' then
OpenDialog1.InitialDir := HomeDir;
if OpenDialog1.Execute then begin
fn:=OpenDialog1.FileName;
ImportMosaic(fn);
end;
end;

procedure Tf_obslist.BtnTourClick(Sender: TObject);
begin
tour := Tf_tour.Create(self);
Expand Down
1 change: 1 addition & 0 deletions skychart/u_translation.pas
Expand Up @@ -1551,6 +1551,7 @@ function Translate(lang: string = ''): string;
rsReplaceByTic = 'Replace by tick mark';
rsSpeed = 'Speed';
rsFillNebulae = 'Fill nebulae';
rsImportMosaic = 'Import mosaic file';

// also update upsi_translation

Expand Down

0 comments on commit 5685ce4

Please sign in to comment.