/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/CBuilder/EclipseU.cpp
ViewVC logotype

Annotation of /dao/DelphiScanner/Components/tpsystools_4.04/examples/CBuilder/EclipseU.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (hide annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 6111 byte(s)
Added tpsystools component
1 torben 2671 // ***** BEGIN LICENSE BLOCK *****
2     // * Version: MPL 1.1
3     // *
4     // * The contents of this file are subject to the Mozilla Public License Version
5     // * 1.1 (the "License"); you may not use this file except in compliance with
6     // * the License. You may obtain a copy of the License at
7     // * http://www.mozilla.org/MPL/
8     // *
9     // * Software distributed under the License is distributed on an "AS IS" basis,
10     // * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11     // * for the specific language governing rights and limitations under the
12     // * License.
13     // *
14     // * The Original Code is TurboPower SysTools
15     // *
16     // * The Initial Developer of the Original Code is
17     // * TurboPower Software
18     // *
19     // * Portions created by the Initial Developer are Copyright (C) 1996-2002
20     // * the Initial Developer. All Rights Reserved.
21     // *
22     // * Contributor(s):
23     // *
24     // * ***** END LICENSE BLOCK *****
25     //---------------------------------------------------------------------------
26     #include <vcl\vcl.h>
27     #pragma hdrstop
28    
29     #include "EclipseU.h"
30     //---------------------------------------------------------------------------
31     #pragma package(smart_init)
32     #pragma link "StEclpse"
33    
34     #pragma resource "*.dfm"
35     TForm1 *Form1;
36     //---------------------------------------------------------------------------
37     __fastcall TForm1::TForm1(TComponent* Owner)
38     : TForm(Owner)
39     {
40     }
41     //---------------------------------------------------------------------------
42     void TForm1::WriteLunarData(TStEclipseRecord Eclipse)
43     {
44     String S;
45    
46     switch (Eclipse.EType) {
47     case etLunarPenumbral : {Memo1->Lines->Add("Lunar - Penumbra"); break;};
48     case etLunarPartial : {Memo1->Lines->Add("Lunar - Partial"); break;};
49     case etLunarTotal : {Memo1->Lines->Add("Lunar - Total"); break;};
50     };
51     S = Format("%0:3f", OPENARRAY(TVarRec, (Eclipse.Magnitude)));
52    
53     Memo1->Lines->Add("Mag: " + S);
54     Memo1->Lines->Add("Penumbral Starts: " + DateTimeToStr(Eclipse.LContacts.UT1));
55     Memo1->Lines->Add("First Contact: " + DateTimeToStr(Eclipse.LContacts.FirstContact));
56     Memo1->Lines->Add("Second Contact: " + DateTimeToStr(Eclipse.LContacts.SecondContact));
57     Memo1->Lines->Add("Mid Eclipse " + DateTimeToStr(Eclipse.LContacts.MidEclipse));
58     Memo1->Lines->Add("Third Contact: " + DateTimeToStr(Eclipse.LContacts.ThirdContact));
59     Memo1->Lines->Add("Fourth Contact: " + DateTimeToStr(Eclipse.LContacts.FourthContact));
60     Memo1->Lines->Add("Penumbral Ends: " + DateTimeToStr(Eclipse.LContacts.UT2));
61    
62     Memo1->Lines->Add("");
63     Memo1->Lines->Add("");
64     Memo1->Lines->Add("");
65     }
66     //---------------------------------------------------------------------------
67     void TForm1::WriteSolarData(TStEclipseRecord Eclipse)
68     {
69     int I;
70     String S, P;
71     TStLongLat LL;
72    
73     switch (Eclipse.EType) {
74     case etSolarPartial :
75     {
76     Memo1->Lines->Add("Solar - Partial");
77     S = Format("%0:3f", OPENARRAY(TVarRec, (Eclipse.Magnitude)));
78     Memo1->Lines->Add("Mag: " + S);
79     if (Eclipse.Hemisphere == htNorthern) {
80     Memo1->Lines->Add("Hemisphere: Northern");
81     }
82     else {
83     Memo1->Lines->Add("Hemisphere: Southern");
84     }
85     Memo1->Lines->Add("Mid Eclipse: " +
86     DateTimeToStr(Eclipse.LContacts.MidEclipse));
87     break;
88     };
89     case etSolarTotal :
90     {
91     Memo1->Lines->Add("Solar - Total");
92     Memo1->Lines->Add("Mag: N/A");
93     if (Eclipse.Hemisphere == htNorthern) {
94     Memo1->Lines->Add("Hemisphere: Northern");
95     }
96     else {
97     Memo1->Lines->Add("Hemisphere: Southern");
98     }
99     Memo1->Lines->Add("Mid Eclipse: " +
100     DateTimeToStr(Eclipse.LContacts.MidEclipse));
101     break;
102     };
103     case etSolarAnnularTotal :
104     {
105     S = Format("%0:3f", OPENARRAY(TVarRec, (Eclipse.Magnitude)));
106     Memo1->Lines->Add("Mag: N/A");
107     if (Eclipse.Hemisphere == htNorthern) {
108     Memo1->Lines->Add("Hemisphere: Northern");
109     }
110     else {
111     Memo1->Lines->Add("Hemisphere: Southern");
112     }
113     Memo1->Lines->Add("Mid Eclipse: " +
114     DateTimeToStr(Eclipse.LContacts.MidEclipse));
115     break;
116     }
117     case etSolarAnnular :
118     {
119     Memo1->Lines->Add("Solar - Annular");
120     Memo1->Lines->Add("Mag: N/A");
121     if (Eclipse.Hemisphere == htNorthern) {
122     Memo1->Lines->Add("Hemisphere: Northern");
123     }
124     else {
125     Memo1->Lines->Add("Hemisphere: Southern");
126     }
127     Memo1->Lines->Add("Mid Eclipse: " +
128     DateTimeToStr(Eclipse.LContacts.MidEclipse));
129     break;
130     }
131     };
132    
133     if (Eclipse.Path) {
134     for (I = 0; I < Eclipse.Path->Count; I++) {
135     LL = *(TStLongLat*)Eclipse.Path->Items[I]->Data;
136     P = " " + DateTimeToStr(LL.JD) + " ";
137    
138     S = Format("%0:2f", OPENARRAY(TVarRec, (LL.Longitude)));
139     P = P + S + " ";
140    
141     S = Format("%0:2f", OPENARRAY(TVarRec, (LL.Latitude)));
142     P = P + S + " ";
143    
144     S = Format("%0:2f", OPENARRAY(TVarRec, (LL.Duration)));
145     P = P + S;
146     Memo1->Lines->Add(P);
147     };
148     };
149    
150     Memo1->Lines->Add("");
151     Memo1->Lines->Add("");
152     Memo1->Lines->Add("");
153     }
154     //---------------------------------------------------------------------------
155     void __fastcall TForm1::Button1Click(TObject *Sender)
156     {
157     int I;
158     TStEclipseRecord Eclipse;
159    
160     Memo1->Clear();
161     TStEclipses* Data = new TStEclipses(__classid(TStListNode));
162     try {
163     Data->FindEclipses(StrToInt(YearEF->Text));
164     for (I = 0; I < Data->Count; I++) {
165     Eclipse = (TStEclipseRecord)*Data->Eclipses[I];
166     if ((Eclipse.EType == etLunarPenumbral) || (Eclipse.EType == etLunarPartial) ||
167     (Eclipse.EType == etLunarTotal)) {
168     WriteLunarData(Eclipse);
169     }
170     else {
171     WriteSolarData(Eclipse);
172     }
173     }
174     delete Data;
175     }
176     catch(...) {
177     delete Data;
178     throw;
179     };
180     }
181     //---------------------------------------------------------------------------
182    

  ViewVC Help
Powered by ViewVC 1.1.20