home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl\vcl.h>
- #pragma hdrstop
-
- #include "math.h"
- #include "Main.h"
- #include "about.h"
- #include "report.h"
- //---------------------------------------------------------------------------
- #pragma resource "*.dfm"
- TMainForm *MainForm;
- //---------------------------------------------------------------------------
- __fastcall TMainForm::TMainForm(TComponent* Owner)
- : TForm(Owner)
- {
- Db->Params->Values["PATH"] = Application->ExeName.SubString (0,Application->ExeName.LastDelimiter ("\\") - 1);
- Table->Active = true;
- }
- //----------------------------------------------------------------------------
- void __fastcall TMainForm::GetFunction (double &AX,double &AY,double AFi,int AIndex)
- {
- double a,b,l;
-
- switch (AIndex)
- {
- case 0:
- a = 2;
- b = 5;
- AX = (a+b)*cos(AFi) - a*cos((a+b)*AFi/a);
- AY = (a+b)*sin(AFi) - a*sin((a+b)*AFi/a);
- break;
- case 1:
- a = 2;
- b = 12;
- AX = (b-a)*cos(AFi) + a*cos((b-a)*AFi/a);
- AY = (b-a)*sin(AFi) - a*sin((b-a)*AFi/a);
- break;
- case 2:
- a = 2;
- b = 8;
- l = 2;
- AX = (b-a)*cos(AFi) + l*a*cos((b-a)*AFi/a);
- AY = (b-a)*sin(AFi) - l*a*sin((b-a)*AFi/a);
- break;
- }
- }
-
- void __fastcall TMainForm::Solve(void)
- {
- double x,y,fi;
- TCurvePoint *APoint;
-
- RepForm->Curve1->CurveData->Items[0]->CurvePoints->Clear ();
- DSource->Enabled = false;
- Table->EmptyTable ();
-
- for (fi=0; fi<=4*M_PI; fi+=M_PI/30)
- {
- GetFunction (x,y,fi,Group1->ItemIndex);
- APoint = (TCurvePoint *)(RepForm->Curve1->CurveData->Items[0]->CurvePoints->Add ());
- APoint->Argument->Value = x;
- APoint->Function->Value = y;
-
- GetFunction (x,y,fi,Group2->ItemIndex);
- Table->AppendRecord (ARRAYOFCONST(((double)x,(double)y)));
- }
-
- DSource->Enabled = true;
-
- ((TLegendAbsString *)RepForm->Curve1->Legend->Data)->Value = Group1->Items->Strings[Group1->ItemIndex];
- ((TLegendAbsString *)RepForm->Curve2->Legend->Data)->Value = Group2->Items->Strings[Group2->ItemIndex];
- }
- //----------------------------------------------------------------------------
- void __fastcall TMainForm::Print(TObject *Sender)
- {
- Solve ();
- if (RepForm->VividReport->PrintSetup ()) RepForm->VividReport->Print ();
- }
- //----------------------------------------------------------------------------
- void __fastcall TMainForm::PrintSetup(TObject *Sender)
- {
- RepForm->VividReport->PrinterSetup ();
- }
- //----------------------------------------------------------------------------
- void __fastcall TMainForm::Exit(TObject *Sender)
- {
- Close();
- }
- //----------------------------------------------------------------------------
- void __fastcall TMainForm::About(TObject *Sender)
- {
- AboutBox->ShowModal ();
- }
- //----------------------------------------------------------------------------
- void __fastcall TMainForm::PrintPreview(TObject *Sender)
- {
- Solve ();
- RepForm->VividReport->PrintPreview (RepForm->VRPreview);
- }
- //---------------------------------------------------------------------------
-
-
-
-