mirror of
https://github.com/ulfgebhardt/delphi_plotter.git
synced 2025-12-13 07:45:58 +00:00
Initial Commit
This commit is contained in:
parent
6f395c0fac
commit
bbba40228c
35
Plotter.cfg
Normal file
35
Plotter.cfg
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
-$A8
|
||||||
|
-$B-
|
||||||
|
-$C+
|
||||||
|
-$D+
|
||||||
|
-$E-
|
||||||
|
-$F-
|
||||||
|
-$G+
|
||||||
|
-$H+
|
||||||
|
-$I+
|
||||||
|
-$J-
|
||||||
|
-$K-
|
||||||
|
-$L+
|
||||||
|
-$M-
|
||||||
|
-$N+
|
||||||
|
-$O+
|
||||||
|
-$P+
|
||||||
|
-$Q-
|
||||||
|
-$R-
|
||||||
|
-$S-
|
||||||
|
-$T-
|
||||||
|
-$U-
|
||||||
|
-$V+
|
||||||
|
-$W-
|
||||||
|
-$X+
|
||||||
|
-$YD
|
||||||
|
-$Z1
|
||||||
|
-cg
|
||||||
|
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||||
|
-H+
|
||||||
|
-W+
|
||||||
|
-M
|
||||||
|
-$M16384,1048576
|
||||||
|
-K$00400000
|
||||||
|
-LE"c:\program files (x86)\delphi6\Projects\Bpl"
|
||||||
|
-LN"c:\program files (x86)\delphi6\Projects\Bpl"
|
||||||
87
Plotter.dof
Normal file
87
Plotter.dof
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
[FileVersion]
|
||||||
|
Version=6.0
|
||||||
|
[Compiler]
|
||||||
|
A=8
|
||||||
|
B=0
|
||||||
|
C=1
|
||||||
|
D=1
|
||||||
|
E=0
|
||||||
|
F=0
|
||||||
|
G=1
|
||||||
|
H=1
|
||||||
|
I=1
|
||||||
|
J=0
|
||||||
|
K=0
|
||||||
|
L=1
|
||||||
|
M=0
|
||||||
|
N=1
|
||||||
|
O=1
|
||||||
|
P=1
|
||||||
|
Q=0
|
||||||
|
R=0
|
||||||
|
S=0
|
||||||
|
T=0
|
||||||
|
U=0
|
||||||
|
V=1
|
||||||
|
W=0
|
||||||
|
X=1
|
||||||
|
Y=1
|
||||||
|
Z=1
|
||||||
|
ShowHints=1
|
||||||
|
ShowWarnings=1
|
||||||
|
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||||
|
[Linker]
|
||||||
|
MapFile=0
|
||||||
|
OutputObjs=0
|
||||||
|
ConsoleApp=1
|
||||||
|
DebugInfo=0
|
||||||
|
RemoteSymbols=0
|
||||||
|
MinStackSize=16384
|
||||||
|
MaxStackSize=1048576
|
||||||
|
ImageBase=4194304
|
||||||
|
ExeDescription=
|
||||||
|
[Directories]
|
||||||
|
OutputDir=
|
||||||
|
UnitOutputDir=
|
||||||
|
PackageDLLOutputDir=
|
||||||
|
PackageDCPOutputDir=
|
||||||
|
SearchPath=
|
||||||
|
Packages=
|
||||||
|
Conditionals=
|
||||||
|
DebugSourceDirs=
|
||||||
|
UsePackages=0
|
||||||
|
[Parameters]
|
||||||
|
RunParams=
|
||||||
|
HostApplication=
|
||||||
|
Launcher=
|
||||||
|
UseLauncher=0
|
||||||
|
DebugCWD=
|
||||||
|
[Language]
|
||||||
|
ActiveLang=
|
||||||
|
ProjectLang=
|
||||||
|
RootDir=
|
||||||
|
[Version Info]
|
||||||
|
IncludeVerInfo=0
|
||||||
|
AutoIncBuild=0
|
||||||
|
MajorVer=1
|
||||||
|
MinorVer=0
|
||||||
|
Release=0
|
||||||
|
Build=0
|
||||||
|
Debug=0
|
||||||
|
PreRelease=0
|
||||||
|
Special=0
|
||||||
|
Private=0
|
||||||
|
DLL=0
|
||||||
|
Locale=1031
|
||||||
|
CodePage=1252
|
||||||
|
[Version Info Keys]
|
||||||
|
CompanyName=
|
||||||
|
FileDescription=
|
||||||
|
FileVersion=1.0.0.0
|
||||||
|
InternalName=
|
||||||
|
LegalCopyright=
|
||||||
|
LegalTrademarks=
|
||||||
|
OriginalFilename=
|
||||||
|
ProductName=
|
||||||
|
ProductVersion=1.0.0.0
|
||||||
|
Comments=
|
||||||
14
Plotter.dpr
Normal file
14
Plotter.dpr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
program Plotter;
|
||||||
|
|
||||||
|
uses
|
||||||
|
Forms,
|
||||||
|
fgraph in 'fgraph.pas' {fGraph},
|
||||||
|
graph in 'graph.pas';
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
begin
|
||||||
|
Application.Initialize;
|
||||||
|
Application.CreateForm(TfGraph, formGraph);
|
||||||
|
Application.Run;
|
||||||
|
end.
|
||||||
BIN
Plotter.res
Normal file
BIN
Plotter.res
Normal file
Binary file not shown.
174
fgraph.dfm
Normal file
174
fgraph.dfm
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
object fGraph: TfGraph
|
||||||
|
Left = 216
|
||||||
|
Top = 178
|
||||||
|
BorderStyle = bsNone
|
||||||
|
Caption = 'fGraph'
|
||||||
|
ClientHeight = 514
|
||||||
|
ClientWidth = 699
|
||||||
|
Color = clSkyBlue
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -11
|
||||||
|
Font.Name = 'MS Sans Serif'
|
||||||
|
Font.Style = []
|
||||||
|
OldCreateOrder = False
|
||||||
|
Position = poScreenCenter
|
||||||
|
OnCreate = FormCreate
|
||||||
|
OnMouseWheelDown = FormMouseWheelDown
|
||||||
|
OnMouseWheelUp = FormMouseWheelUp
|
||||||
|
OnPaint = FormPaint
|
||||||
|
OnResize = FormResize
|
||||||
|
PixelsPerInch = 96
|
||||||
|
TextHeight = 13
|
||||||
|
object ptop: TPanel
|
||||||
|
Left = 0
|
||||||
|
Top = 0
|
||||||
|
Width = 699
|
||||||
|
Height = 33
|
||||||
|
Align = alTop
|
||||||
|
BevelOuter = bvNone
|
||||||
|
Color = clSkyBlue
|
||||||
|
TabOrder = 0
|
||||||
|
DesignSize = (
|
||||||
|
699
|
||||||
|
33)
|
||||||
|
object lheader: TLabel
|
||||||
|
Left = 0
|
||||||
|
Top = 0
|
||||||
|
Width = 699
|
||||||
|
Height = 33
|
||||||
|
Align = alClient
|
||||||
|
Alignment = taCenter
|
||||||
|
Caption = 'Plotter Graph'
|
||||||
|
Font.Charset = ANSI_CHARSET
|
||||||
|
Font.Color = clGreen
|
||||||
|
Font.Height = -24
|
||||||
|
Font.Name = 'Comic Sans MS'
|
||||||
|
Font.Style = []
|
||||||
|
ParentFont = False
|
||||||
|
end
|
||||||
|
object lexit: TLabel
|
||||||
|
Left = 674
|
||||||
|
Top = 8
|
||||||
|
Width = 25
|
||||||
|
Height = 41
|
||||||
|
Anchors = [akTop, akRight]
|
||||||
|
AutoSize = False
|
||||||
|
Caption = 'X'
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -19
|
||||||
|
Font.Name = 'Comic Sans MS'
|
||||||
|
Font.Style = []
|
||||||
|
ParentFont = False
|
||||||
|
OnMouseDown = lexitMouseDown
|
||||||
|
OnMouseMove = lexitMouseMove
|
||||||
|
OnMouseLeave = lexitMouseLeave
|
||||||
|
end
|
||||||
|
object lmax: TLabel
|
||||||
|
Left = 658
|
||||||
|
Top = 0
|
||||||
|
Width = 15
|
||||||
|
Height = 41
|
||||||
|
Anchors = [akTop, akRight]
|
||||||
|
AutoSize = False
|
||||||
|
Caption = '^'
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -19
|
||||||
|
Font.Name = 'Comic Sans MS'
|
||||||
|
Font.Style = []
|
||||||
|
ParentFont = False
|
||||||
|
OnMouseDown = lmaxMouseDown
|
||||||
|
OnMouseMove = lmaxMouseMove
|
||||||
|
OnMouseLeave = lmaxMouseLeave
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object pleft: TPanel
|
||||||
|
Left = 0
|
||||||
|
Top = 33
|
||||||
|
Width = 41
|
||||||
|
Height = 440
|
||||||
|
Align = alLeft
|
||||||
|
BevelOuter = bvNone
|
||||||
|
Color = clSkyBlue
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object pbottom: TPanel
|
||||||
|
Left = 0
|
||||||
|
Top = 473
|
||||||
|
Width = 699
|
||||||
|
Height = 41
|
||||||
|
Align = alBottom
|
||||||
|
BevelOuter = bvNone
|
||||||
|
Color = clSkyBlue
|
||||||
|
TabOrder = 2
|
||||||
|
object Edit1: TEdit
|
||||||
|
Left = 32
|
||||||
|
Top = 8
|
||||||
|
Width = 217
|
||||||
|
Height = 21
|
||||||
|
TabOrder = 0
|
||||||
|
Text = 'x^2 + x^3'
|
||||||
|
end
|
||||||
|
object Button1: TButton
|
||||||
|
Left = 256
|
||||||
|
Top = 8
|
||||||
|
Width = 75
|
||||||
|
Height = 25
|
||||||
|
Caption = 'Evaluate'
|
||||||
|
TabOrder = 1
|
||||||
|
OnClick = Button1Click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object pright: TPanel
|
||||||
|
Left = 657
|
||||||
|
Top = 33
|
||||||
|
Width = 42
|
||||||
|
Height = 440
|
||||||
|
Align = alRight
|
||||||
|
BevelOuter = bvNone
|
||||||
|
Color = clSkyBlue
|
||||||
|
TabOrder = 3
|
||||||
|
DesignSize = (
|
||||||
|
42
|
||||||
|
440)
|
||||||
|
object lmin: TLabel
|
||||||
|
Left = 8
|
||||||
|
Top = -12
|
||||||
|
Width = 26
|
||||||
|
Height = 25
|
||||||
|
Alignment = taRightJustify
|
||||||
|
Anchors = [akTop, akRight]
|
||||||
|
AutoSize = False
|
||||||
|
Caption = '_'
|
||||||
|
Font.Charset = DEFAULT_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -19
|
||||||
|
Font.Name = 'Comic Sans MS'
|
||||||
|
Font.Style = []
|
||||||
|
ParentFont = False
|
||||||
|
OnClick = lminClick
|
||||||
|
OnMouseMove = lminMouseMove
|
||||||
|
OnMouseLeave = lminMouseLeave
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object pmiddle: TPanel
|
||||||
|
Left = 41
|
||||||
|
Top = 33
|
||||||
|
Width = 616
|
||||||
|
Height = 440
|
||||||
|
Align = alClient
|
||||||
|
BevelOuter = bvNone
|
||||||
|
Color = clWhite
|
||||||
|
TabOrder = 4
|
||||||
|
object iGraph: TImage
|
||||||
|
Left = 0
|
||||||
|
Top = 0
|
||||||
|
Width = 616
|
||||||
|
Height = 440
|
||||||
|
Align = alClient
|
||||||
|
OnClick = iGraphClick
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
246
fgraph.pas
Normal file
246
fgraph.pas
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
unit fgraph;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
|
Dialogs, ExtCtrls, StdCtrls, graph;
|
||||||
|
|
||||||
|
type
|
||||||
|
TfGraph = class(TForm)
|
||||||
|
ptop: TPanel;
|
||||||
|
pleft: TPanel;
|
||||||
|
pbottom: TPanel;
|
||||||
|
pright: TPanel;
|
||||||
|
pmiddle: TPanel;
|
||||||
|
iGraph: TImage;
|
||||||
|
lheader: TLabel;
|
||||||
|
lexit: TLabel;
|
||||||
|
lmax: TLabel;
|
||||||
|
lmin: TLabel;
|
||||||
|
Edit1: TEdit;
|
||||||
|
Button1: TButton;
|
||||||
|
procedure lexitMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
procedure lexitMouseLeave(Sender: TObject);
|
||||||
|
procedure lexitMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
procedure lmaxMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
procedure lmaxMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
procedure lmaxMouseLeave(Sender: TObject);
|
||||||
|
procedure FormPaint(Sender: TObject);
|
||||||
|
procedure FormResize(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure lminMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
procedure lminMouseLeave(Sender: TObject);
|
||||||
|
procedure lminClick(Sender: TObject);
|
||||||
|
procedure iGraphClick(Sender: TObject);
|
||||||
|
procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
|
||||||
|
MousePos: TPoint; var Handled: Boolean);
|
||||||
|
procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
|
||||||
|
MousePos: TPoint; var Handled: Boolean);
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
|
private
|
||||||
|
{ Private-Deklarationen }
|
||||||
|
public
|
||||||
|
{ Public-Deklarationen }
|
||||||
|
graph:TGraph;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
formGraph: TfGraph;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
procedure TfGraph.lexitMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
lexit.Font.Color:=clred;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lexitMouseLeave(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
lexit.Font.Color:=clblack;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lexitMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
Application.Terminate;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lmaxMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
if formGraph.WindowState=wsmaximized then formGraph.WindowState:=wsnormal else formGraph.WindowState:=wsmaximized;
|
||||||
|
|
||||||
|
graph.drawAchsis;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lmaxMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
lmax.Font.Color:=clred;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lmaxMouseLeave(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
lmax.Font.Color:=clblack;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.FormPaint(Sender: TObject);
|
||||||
|
var rgn: HRGN;
|
||||||
|
begin
|
||||||
|
|
||||||
|
if windowstate=wsmaximized then
|
||||||
|
begin
|
||||||
|
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
|
||||||
|
0, // y-coordinate of the region's upper-left corner
|
||||||
|
ClientWidth, // x-coordinate of the region's lower-right corner
|
||||||
|
ClientHeight, // y-coordinate of the region's lower-right corner
|
||||||
|
0, // height of ellipse for rounded corners
|
||||||
|
0); // width of ellipse for rounded corners
|
||||||
|
SetWindowRgn(Handle, rgn, True);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
|
||||||
|
0, // y-coordinate of the region's upper-left corner
|
||||||
|
ClientWidth, // x-coordinate of the region's lower-right corner
|
||||||
|
ClientHeight, // y-coordinate of the region's lower-right corner
|
||||||
|
25, // height of ellipse for rounded corners
|
||||||
|
25); // width of ellipse for rounded corners
|
||||||
|
SetWindowRgn(Handle, rgn, True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
|
||||||
|
0, // y-coordinate of the region's upper-left corner
|
||||||
|
pmiddle.Width, // x-coordinate of the region's lower-right corner
|
||||||
|
pmiddle.Height, // y-coordinate of the region's lower-right corner
|
||||||
|
25, // height of ellipse for rounded corners
|
||||||
|
25); // width of ellipse for rounded corners
|
||||||
|
SetWindowRgn(pmiddle.Handle, rgn, True);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.FormResize(Sender: TObject);
|
||||||
|
var rgn: HRGN;
|
||||||
|
begin
|
||||||
|
|
||||||
|
if windowstate=wsmaximized then
|
||||||
|
begin
|
||||||
|
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
|
||||||
|
0, // y-coordinate of the region's upper-left corner
|
||||||
|
ClientWidth, // x-coordinate of the region's lower-right corner
|
||||||
|
ClientHeight, // y-coordinate of the region's lower-right corner
|
||||||
|
0, // height of ellipse for rounded corners
|
||||||
|
0); // width of ellipse for rounded corners
|
||||||
|
SetWindowRgn(Handle, rgn, True);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
|
||||||
|
0, // y-coordinate of the region's upper-left corner
|
||||||
|
ClientWidth, // x-coordinate of the region's lower-right corner
|
||||||
|
ClientHeight, // y-coordinate of the region's lower-right corner
|
||||||
|
25, // height of ellipse for rounded corners
|
||||||
|
25); // width of ellipse for rounded corners
|
||||||
|
SetWindowRgn(Handle, rgn, True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.FormCreate(Sender: TObject);
|
||||||
|
var rgn: HRGN;
|
||||||
|
begin
|
||||||
|
|
||||||
|
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
|
||||||
|
0, // y-coordinate of the region's upper-left corner
|
||||||
|
ClientWidth, // x-coordinate of the region's lower-right corner
|
||||||
|
ClientHeight, // y-coordinate of the region's lower-right corner
|
||||||
|
25, // height of ellipse for rounded corners
|
||||||
|
25); // width of ellipse for rounded corners
|
||||||
|
SetWindowRgn(Handle, rgn, True);
|
||||||
|
|
||||||
|
graph:=TGraph.create;
|
||||||
|
|
||||||
|
graph.init(50,50,iGraph);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lminMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
lmin.Font.Color:=clred;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lminMouseLeave(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
lmin.Font.Color:=clblack;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.lminClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
Application.Minimize;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.iGraphClick(Sender: TObject);
|
||||||
|
var point:TPoint;
|
||||||
|
begin
|
||||||
|
|
||||||
|
getcursorpos(point);
|
||||||
|
|
||||||
|
graph.drawAchsis(point.x-formGraph.left-pleft.width,screen.Height-point.y-(screen.Height-formgraph.Height-formgraph.Top)-(formgraph.pbottom.Height));
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
|
||||||
|
MousePos: TPoint; var Handled: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
graph.ZeichenAbstandX:=graph.ZeichenAbstandX-1;
|
||||||
|
graph.ZeichenAbstandY:=graph.ZeichenAbstandY-1;
|
||||||
|
graph.drawAchsis;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
|
||||||
|
MousePos: TPoint; var Handled: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
graph.ZeichenAbstandX:=graph.ZeichenAbstandX+1;
|
||||||
|
graph.ZeichenAbstandY:=graph.ZeichenAbstandY+1;
|
||||||
|
graph.drawAchsis;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfGraph.Button1Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
graph.drawFunction(edit1.Text);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
138
graph.pas
Normal file
138
graph.pas
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
unit graph;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses windows, ExtCtrls, sysutils, parser, graphics, dialogs;
|
||||||
|
|
||||||
|
type TGraph = class
|
||||||
|
public
|
||||||
|
Ursprung:TPoint;
|
||||||
|
Bild:TImage;
|
||||||
|
ZeichenAbstandX:integer;
|
||||||
|
ZeichenAbstandY:integer;
|
||||||
|
ZeichenSchrittX:integer;
|
||||||
|
ZeichenSchrittY:integer;
|
||||||
|
|
||||||
|
procedure drawAchsis; overload;
|
||||||
|
procedure drawAchsis(Ursprungx,Ursprungy:integer); overload;
|
||||||
|
procedure init(Ursprungx,Ursprungy:integer;pBild:TImage);
|
||||||
|
procedure leereBild;
|
||||||
|
procedure drawPoint(x,y:integer);
|
||||||
|
procedure drawFunction(formalstr:string);
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure TGraph.drawFunction(formalstr:string);
|
||||||
|
var Expression:IExpr1V;
|
||||||
|
i:extended;
|
||||||
|
begin
|
||||||
|
|
||||||
|
expression:=compileStr1V(formalstr);
|
||||||
|
if Expression.getErrInfo.ErrPos > 0 then messagedlg(Expression.getErrStr,mtwarning, [MBok],0) else
|
||||||
|
begin
|
||||||
|
i:=-(Bild.Width div ZeichenAbstandX);
|
||||||
|
repeat
|
||||||
|
try
|
||||||
|
drawPoint(round(i*ZeichenAbstandX),round(expression.eval(i)*ZeichenAbstandX));
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
i:=i+0.001;
|
||||||
|
until i >=(Bild.Width div ZeichenAbstandX);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGraph.drawPoint(x,y:integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
Bild.Canvas.Pixels[Ursprung.X+x,Ursprung.Y-y]:=clred;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGraph.init(Ursprungx,Ursprungy:integer;pBild:TImage);
|
||||||
|
begin
|
||||||
|
|
||||||
|
Bild:=pBild;
|
||||||
|
|
||||||
|
Ursprung.x:=Ursprungx;
|
||||||
|
Ursprung.y:=bild.Height-ursprungy;
|
||||||
|
|
||||||
|
ZeichenAbstandX:=50;
|
||||||
|
ZeichenAbstandY:=50;
|
||||||
|
ZeichenSchrittX:=1;
|
||||||
|
ZeichenSchrittY:=1;
|
||||||
|
|
||||||
|
drawAchsis;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGraph.drawAchsis;
|
||||||
|
var i:integer;
|
||||||
|
begin
|
||||||
|
|
||||||
|
if ZeichenAbstandX<5 then ZeichenAbstandX:=5;
|
||||||
|
if ZeichenAbstandY<5 then ZeichenAbstandY:=5;
|
||||||
|
|
||||||
|
leereBild;
|
||||||
|
|
||||||
|
//Linie X:
|
||||||
|
Bild.Canvas.MoveTo(0,ursprung.Y);
|
||||||
|
Bild.Canvas.LineTo(bild.Width,ursprung.y);
|
||||||
|
|
||||||
|
//Line Y:
|
||||||
|
Bild.Canvas.MoveTo(ursprung.x,0);
|
||||||
|
Bild.Canvas.LineTo(ursprung.x,bild.height);
|
||||||
|
|
||||||
|
// Abschnitte X positiv
|
||||||
|
for i:=1 to (Bild.Width div ZeichenAbstandX) do
|
||||||
|
begin
|
||||||
|
Bild.Canvas.MoveTo(Ursprung.x+(ZeichenAbstandX*i),Ursprung.y+3);
|
||||||
|
Bild.Canvas.LineTo(Ursprung.x+(ZeichenAbstandX*i),Ursprung.y-3);
|
||||||
|
Bild.Canvas.TextOut(Ursprung.x+(ZeichenAbstandX*i)-3,Ursprung.y+6,inttostr(ZeichenSchrittY*i));
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Abschnitte X negativ
|
||||||
|
for i:=1 to (Bild.Width div ZeichenAbstandX) do
|
||||||
|
begin
|
||||||
|
Bild.Canvas.MoveTo(Ursprung.x-(ZeichenAbstandX*i),Ursprung.y+3);
|
||||||
|
Bild.Canvas.LineTo(Ursprung.x-(ZeichenAbstandX*i),Ursprung.y-3);
|
||||||
|
Bild.Canvas.TextOut(Ursprung.x-(ZeichenAbstandX*i)-3,Ursprung.y+6,inttostr(ZeichenSchrittY*i));
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Abschnitte Y negativ
|
||||||
|
for i:=1 to (Bild.height div ZeichenAbstandY) do
|
||||||
|
begin
|
||||||
|
Bild.Canvas.MoveTo(Ursprung.x+3,Ursprung.Y+(ZeichenAbstandY*i));
|
||||||
|
Bild.Canvas.LineTo(Ursprung.x-4,Ursprung.Y+(ZeichenAbstandY*i));
|
||||||
|
Bild.Canvas.TextOut(Ursprung.x-(length(inttostr(ZeichenSchrittY*i))*6)-5,Ursprung.y+(ZeichenAbstandy*i)-4,inttostr(ZeichenSchrittY*i));
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Abschnitte Y positiv
|
||||||
|
for i:=1 to (Bild.height div ZeichenAbstandY) do
|
||||||
|
begin
|
||||||
|
Bild.Canvas.MoveTo(Ursprung.x+3,Ursprung.Y-(ZeichenAbstandY*i));
|
||||||
|
Bild.Canvas.LineTo(Ursprung.x-4,Ursprung.Y-(ZeichenAbstandY*i));
|
||||||
|
Bild.Canvas.TextOut(Ursprung.x-(length(inttostr(ZeichenSchrittY*i))*6)-5,Ursprung.y-(ZeichenAbstandy*i)-4,inttostr(ZeichenSchrittY*i));
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Tgraph.leereBild;
|
||||||
|
begin
|
||||||
|
|
||||||
|
Bild.picture:=nil;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGraph.drawAchsis(Ursprungx,Ursprungy:integer);
|
||||||
|
begin
|
||||||
|
|
||||||
|
Ursprung.x:=Ursprungx;
|
||||||
|
Ursprung.y:=bild.Height-ursprungy;
|
||||||
|
|
||||||
|
drawAchsis;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
1677
parser.pas
Normal file
1677
parser.pas
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user