File: frmmain.pp

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (78 lines) | stat: -rw-r--r-- 1,651 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
unit frmmain;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, StdCtrls, fpexprpars,exprplotpanel;

type

  { TMainForm }

  TMainForm = class(TForm)
    Button1: TButton;
    EA: TEdit;
    EB: TEdit;
    EC: TEdit;
    LEA: TLabel;
    LEC: TLabel;
    LEB: TLabel;
    Panel1: TPanel;
    PParams: TPanel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
    FPanel : TPlotExpressionPanel;
  public
    { public declarations }
  end; 

var
  MainForm: TMainForm;

implementation

{$R *.lfm}

{ TMainForm }

procedure TMainForm.FormCreate(Sender: TObject);
begin
  FPanel:=TPlotExpressionPanel.Create(Self);
  FPanel.Parent:=Panel1;
  FPanel.Align:=alClient;
  FPanel.Identifiers.AddFloatVariable('a',1.0);
  FPanel.Identifiers.AddFloatVariable('b',0);
  FPanel.Identifiers.AddFloatVariable('c',0);
  FPanel.XAxis.Origin:=-30;
  FPanel.XAxis.DrawZero:=True;
  FPanel.YAxis.Caption.Alignment:=taCenter;
  FPanel.YAxis.Origin:=-10;
  FPanel.YAxis.DrawZero:=True;
  FPanel.Expression:='a * (x * x) + b * x + c';
  FPanel.Active:=True;
  FPanel.Caption.Title:='Square function demo';
  FPanel.Caption.Alignment:=taRightJustify;
end;

procedure TMainForm.Button1Click(Sender: TObject);

Var
  A,b,c : TExprFloat;

begin
  A:=StrToFLoat(EA.Text);
  b:=StrToFLoat(EB.Text);
  C:=StrToFLoat(EC.Text);
  FPanel.Identifiers.IdentifierByName('a').AsFloat:=A;
  FPanel.Identifiers.IdentifierByName('b').AsFloat:=B;
  FPanel.Identifiers.IdentifierByName('c').AsFloat:=C;
  FPanel.Invalidate;
end;

end.