Upload files to "/"
This commit is contained in:
213
frameluna.pas
Normal file
213
frameluna.pas
Normal file
@@ -0,0 +1,213 @@
|
||||
unit frameluna;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls, astronomy, DateUtils;
|
||||
|
||||
|
||||
function OttieniRisorsa(faseluna:double):string;
|
||||
function DateToLabel(Data:TDateTime):string;
|
||||
|
||||
type
|
||||
|
||||
{ TLunaView }
|
||||
|
||||
TLunaView = class(TFrame)
|
||||
GroupBox1: TGroupBox;
|
||||
Image1: TImage;
|
||||
SizeLuna: TLabel;
|
||||
PicFase1: TImage;
|
||||
PicFase2: TImage;
|
||||
PicFase3: TImage;
|
||||
PicFase4: TImage;
|
||||
Label1: TLabel;
|
||||
Fase1: TLabel;
|
||||
Fase2: TLabel;
|
||||
Fase3: TLabel;
|
||||
Fase4: TLabel;
|
||||
Panel1: TPanel;
|
||||
Panel2: TPanel;
|
||||
procedure ImpostaDataClick(Sender: TObject; Data:TDateTime; orariosimulazione:byte);
|
||||
|
||||
type
|
||||
TFase= (lunanuova, primoquarto, lunapiena, ultimoquarto);
|
||||
TFaseLuna=record
|
||||
tempo:TDateTime;
|
||||
fase:byte; //0=luna nuova 1=primo quarto, 2=piena, 3=ultimo quarto.
|
||||
end;
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TLunaView }
|
||||
|
||||
var
|
||||
percriduzioneluna:double; //descrive quanto è più piccola la luna rispetto alla luna più vicina
|
||||
|
||||
|
||||
procedure TLunaView.ImpostaDataClick(Sender: TObject; Data:TDateTime; orariosimulazione:byte);
|
||||
var
|
||||
illuminazione1:byte;
|
||||
lunadati:TDatiLuna;
|
||||
|
||||
|
||||
|
||||
astrotime:astro_time_t;
|
||||
tempoastrofase:astro_moon_quarter_t;
|
||||
|
||||
i:byte=0;
|
||||
elementi: TFaseLuna;
|
||||
datefasi: array [0..3] of TFaseLuna;
|
||||
risorsa:string; //stringa della lazarus resource delle foto
|
||||
testolabel:string; //testo sotto le immagini
|
||||
faseluna:double;
|
||||
datadati:TDateTime; //questa è la data che si usa per le simulazioni differisce da Data per il valore di orariosimulazione
|
||||
begin
|
||||
astrotime:= astronomy.TDateTimeToAstroTime(Data);
|
||||
datadati:= DateUtils.IncHour(Data,orariosimulazione);
|
||||
//mostra l'illuminazione all'orario impostato nelle impostazioni
|
||||
faseluna:=FaseLunare(datadati);
|
||||
lunadati:=DistanzaLuna(datadati);
|
||||
illuminazione1:= round(IlluminazioneLuna(faseluna));
|
||||
|
||||
Label1.Caption:='Illuminazione '+inttostr(illuminazione1)+'%'+' Distanza '+inttostr(lunadati.distanzakm)+'Km';
|
||||
SizeLuna.Caption:=SysUtils.FormatFloat('0.000',lunadati.diametrogradi)+'°';
|
||||
|
||||
percriduzioneluna:= lunadati.diametrogradi/0.568;
|
||||
|
||||
|
||||
risorsa:=OttieniRisorsa(faseluna);
|
||||
Image1.Picture.PNG.LoadFromResourceName(HInstance, risorsa);
|
||||
|
||||
tempoastrofase:=astronomy.Astronomy_SearchMoonQuarter(astrotime);
|
||||
datefasi[0].tempo:=astronomy.AstroTimeToTDateTime(tempoastrofase.time);
|
||||
datefasi[0].fase:=tempoastrofase.quarter;
|
||||
repeat
|
||||
i:=1+i;
|
||||
|
||||
tempoastrofase:=astronomy.Astronomy_NextMoonQuarter(tempoastrofase);
|
||||
datefasi[i].tempo:=astronomy.AstroTimeToTDateTime(tempoastrofase.time);
|
||||
datefasi[i].fase:=tempoastrofase.quarter;
|
||||
until i=3;
|
||||
|
||||
i:=0;
|
||||
for elementi in datefasi do
|
||||
begin
|
||||
|
||||
{ case elementi.fase of
|
||||
0: risorsa:='LUNANUOVA_SMALL';
|
||||
1: risorsa:='PRIMOQUARTO_SMALL';
|
||||
2: risorsa:='LUNAPIENA_SMALL';
|
||||
3: risorsa:='ULTIMOQUARTO_SMALL';
|
||||
end; }
|
||||
|
||||
case elementi.fase of
|
||||
0: risorsa:='01';
|
||||
1: risorsa:='09';
|
||||
2: risorsa:='15';
|
||||
3: risorsa:='23';
|
||||
end;
|
||||
|
||||
|
||||
// testolabel:= FormatDateTime('dd mmmm', elementi.tempo);
|
||||
testolabel:= DateToLabel(elementi.tempo);
|
||||
|
||||
|
||||
|
||||
case i of
|
||||
0:
|
||||
begin
|
||||
PicFase1.Picture.PNG.LoadFromResourceName(HInstance, risorsa);
|
||||
Fase1.Caption:=testolabel;
|
||||
end;
|
||||
|
||||
1:
|
||||
begin
|
||||
PicFase2.Picture.PNG.LoadFromResourceName(HInstance, risorsa);
|
||||
Fase2.Caption:=testolabel;
|
||||
end;
|
||||
|
||||
2:
|
||||
begin
|
||||
PicFase3.Picture.PNG.LoadFromResourceName(HInstance, risorsa);
|
||||
Fase3.Caption:=testolabel;
|
||||
end;
|
||||
|
||||
3:
|
||||
begin
|
||||
PicFase4.Picture.PNG.LoadFromResourceName(HInstance, risorsa);
|
||||
Fase4.Caption:=testolabel;
|
||||
end;
|
||||
end;
|
||||
|
||||
i:=i+1;
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
function OttieniRisorsa(faseluna:double):string;
|
||||
begin
|
||||
if faseluna<=180 then OttieniRisorsa:=Format('%.2d' ,[round(1+faseluna*0.0833333333)]);
|
||||
if faseluna>=180 then OttieniRisorsa:=Format( '%.2d', [round(16+(faseluna-180)*0.0833333333)]);
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function DateToLabel(Data:TDateTime):string;
|
||||
var
|
||||
mese:string;
|
||||
numero:string;
|
||||
begin
|
||||
|
||||
numero:=SysUtils.FormatCurr('00', DayOf(Data));
|
||||
case MonthOf(Data) of
|
||||
1: mese:='Gennaio';
|
||||
2: mese:='Febbraio';
|
||||
3: mese:='Marzo';
|
||||
4: mese:='Aprile';
|
||||
5: mese:='Maggio';
|
||||
6: mese:='Giugno';
|
||||
7: mese:='Luglio';
|
||||
8: mese:='Agosto';
|
||||
9: mese:='Settembre';
|
||||
10: mese:='Ottobre';
|
||||
11: mese:='Novembre';
|
||||
12: mese:='Dicembre';
|
||||
|
||||
end;
|
||||
|
||||
result:= numero+' '+mese;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user