home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- vivrep20, Db, DBTables, Menus, StdCtrls, ExtCtrls, Buttons;
-
- type
- TMainForm = class(TForm)
- MainMenu: TMainMenu;
- PrintItem: TMenuItem;
- PrintSetupItem: TMenuItem;
- ExitItem: TMenuItem;
- AboutItem: TMenuItem;
- SpeedBar: TPanel;
- SpeedButton1: TSpeedButton; // &Print...
- SpeedButton2: TSpeedButton; // P&rint Setup...
- SpeedButton3: TSpeedButton; // E&xit
- SpeedButton4: TSpeedButton; // &About...
- PrintPreviewItem: TMenuItem;
- SpeedButton5: TSpeedButton;
- Table: TTable;
- DSource: TDataSource;
- Db: TDatabase;
- Group1: TRadioGroup;
- Group2: TRadioGroup;
-
- procedure Print(Sender: TObject);
- procedure PrintSetup(Sender: TObject);
- procedure Exit(Sender: TObject);
- procedure About(Sender: TObject);
- procedure PrintPreview(Sender: TObject);
- private
- { Private declarations }
- procedure GetFunction (var AX,AY: Real; AFi: Real; AIndex: Integer);
- procedure Solve;
- public
- { Public declarations }
- constructor Create (Owner: TComponent); override;
- end;
-
- var
- MainForm: TMainForm;
-
- implementation
-
- uses About, Rep;
-
- {$R *.DFM}
-
- constructor TMainForm.Create (Owner: TComponent);
- begin
- inherited Create (Owner);
-
- Db.Params.Values['PATH'] := Copy (Application.ExeName,0,LastDelimiter ('\',Application.ExeName) - 1);
- Table.Active := true;
- end;
-
- procedure TMainForm.Print(Sender: TObject);
- begin
- Solve;
- if RepForm.VividReport.PrintSetup then RepForm.VividReport.Print;
- end;
-
- procedure TMainForm.PrintSetup(Sender: TObject);
- begin
- RepForm.VividReport.PrinterSetup;
- end;
-
- procedure TMainForm.Exit(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TMainForm.About(Sender: TObject);
- begin
- AboutBox.ShowModal;
- end;
-
- procedure TMainForm.PrintPreview(Sender: TObject);
- begin
- Solve;
- RepForm.VividReport.PrintPreview (RepForm.VRPreview);
- end;
-
- procedure TMainForm.GetFunction (var AX,AY: Real; AFi: Real; AIndex: Integer);
- var
- a,b,l: Real;
- begin
-
- case AIndex of
- 0:
- begin
- 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);
- end;
- 1:
- begin
- 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);
- end;
- 2:
- begin
- 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);
- end;
- end;
- end;
-
- procedure TMainForm.Solve;
- var
- x,y,fi: Real;
- APoint: TCurvePoint;
- begin
- RepForm.Curve1.CurveData.Items[0].CurvePoints.Clear;
- DSource.Enabled := false;
- Table.EmptyTable;
-
- fi := 0;
- while fi <= 4*Pi do
- begin
- GetFunction (x,y,fi,Group1.ItemIndex);
- APoint := RepForm.Curve1.CurveData.Items[0].CurvePoints.Add as TCurvePoint;
- APoint.Argument.Value := x;
- APoint._Function.Value := y;
-
- GetFunction (x,y,fi,Group2.ItemIndex);
- Table.AppendRecord ([x,y]);
- fi := fi + Pi/30;
- end;
-
- DSource.Enabled := true;
-
- (RepForm.Curve1.Legend.Data as TLegendAbsString).Value := Group1.Items.Strings[Group1.ItemIndex];
- (RepForm.Curve2.Legend.Data as TLegendAbsString).Value := Group2.Items.Strings[Group2.ItemIndex];
- end;
-
- end.
-