8
SysUtils, Variants, Classes, Graphics, Controls, Forms,
9
Dialogs, StdCtrls, Buttons, OpenGL1x, OpenGLTokens, GLVectorGeometry,
13
TEvaluateForm = class(TForm)
26
Coordinates: TCheckBox;
29
EditCoordWidth: TEdit;
30
ColorButton: TSpeedButton;
31
ColorDialog: TColorDialog;
33
PopupMenu1: TPopupMenu;
39
procedure FloatKeyPress(Sender: TObject; var Key: Char);
40
procedure BitBtn1Click(Sender: TObject);
41
procedure ColorButtonClick(Sender: TObject);
42
procedure IntPress(Sender: TObject; var Key: Char);
43
procedure EditXKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
44
procedure EditYKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
45
procedure EditCoordWidthKeyUp(Sender: TObject; var Key: Word;
47
procedure CoordinatesClick(Sender: TObject);
48
procedure ToGridsClick(Sender: TObject);
49
procedure dzdx_dzdyClick(Sender: TObject);
50
procedure MenuClick(Sender: TObject);
51
procedure EditArrowKeyPress(Sender: TObject; var Key: Char);
52
procedure EditArrowKeyUp(Sender: TObject; var Key: Word;
55
{ Private declarations }
59
procedure ShowCoords(const x, y, z: TGLFloat; const c, t: Boolean);
61
{ Public declarations }
62
procedure UpdateEvaluate;
63
procedure UpdateCoords;
68
EvaluateForm: TEvaluateForm;
74
IniFiles, uGlobal, Main, uParser, Functions, DerivativeOptions;
78
procedure TEvaluateForm.FloatKeyPress(Sender: TObject; var Key: Char);
80
with Sender as TEdit do
81
if not CharInSet(Key, AnyFloat) then Key := #0;
84
procedure TEvaluateForm.EditXKeyUp(Sender: TObject; var Key: Word;
91
v := StrToFloat(EditX.Text);
95
ViewData.xEvaluate := v;
97
with ViewData do ShowCoords(xEvaluate, yEvaluate, zValue*xyGrid.zScale,
98
CoordChecked, ToGridsChecked);
102
procedure TEvaluateForm.EditYKeyUp(Sender: TObject; var Key: Word;
109
v := StrToFloat(EditY.Text);
113
ViewData.yEvaluate := v;
115
with ViewData do ShowCoords(xEvaluate, yEvaluate, zValue*xyGrid.zScale,
116
CoordChecked, ToGridsChecked);
120
procedure TEvaluateForm.DoEvaluate;
123
x0, y0, x1, y1, z1, x2, y2, z2, dx, dy, dz, Sz: extended;
124
VectorPos, VectorXDir, VectorYDir: TVector;
129
with PlotData do //x1,y2---------------x2,y2
131
x0 := ViewData.xEvaluate; // | |
132
y0 := ViewData.yEvaluate; // | zValue |
134
dy := yInc; // | x0,y0 |
135
x1 := x0 - dx; // | |
136
y1 := y0 - dy; // | |
137
x2 := x0 + dx; // | |
138
y2 := y0 + dy; //x1,y1---------------x2,y1
141
zValue := ParseEvaluateFxy(x0, y0, PlotData.fxyStr, e);{ evaluate z, x0,y0 }
142
EditZ.Text := FloatTostr(zValue);
143
VectorPos := VectorMake(x0, y0, zValue*ViewData.xyGrid.zScale);
145
z1 := ParseEvaluateFxy(x1, y0, PlotData.fxyStr, e); { evaluate z1, x1,y0 }
146
z2 := ParseEvaluateFxy(x2, y0, PlotData.fxyStr, e); { evaluate z2, x2,y0 }
148
dzdx := dz/(x2 - x1); { dzdx = slope wrt x axis }
150
VectorXDir := VectorMake(x2 - x1, 0, dz*ViewData.xyGrid.zScale);
152
0:Editdzdx.Text := FloatToStrF(dzdx, ffNumber, 12, 8);
153
1:Editdzdx.Text := FloatToStrF(RadToDeg(ArcTan(dzdx)), ffNumber, 12, 8)+'°';
154
2:Editdzdx.Text := FloatToStrF(ArcTan(dzdx), ffNumber, 12, 8)+' Rad.';
157
z1 := ParseEvaluateFxy(x0, y1, PlotData.fxyStr, e); { evaluate z1, x0,y1 }
158
z2 := ParseEvaluateFxy(x0, y2, PlotData.fxyStr, e); { evaluate z2, x0,y2 }
160
dzdy := dz/(y2 - y1); { dzdy = slope wrt y axis }
162
VectorYDir := VectorMake(0, y2 - y1, dz*ViewData.xyGrid.zScale);
164
0:Editdzdy.Text := FloatToStrF(dzdy, ffNumber, 12, 8);
165
1:Editdzdy.Text := FloatToStrF(RadToDeg(ArcTan(dzdy)), ffNumber, 12, 8)+'°';
166
2:Editdzdy.Text := FloatToStrF(ArcTan(dzdy), ffNumber, 12, 8)+' Rad.';
169
if dzdx_dzdy.Checked then
171
with ViewData.xyGrid do if xRange.Step < yRange.Step
172
then Sz := xRange.Step else Sz := yRange.Step;
173
with ViewForm.xArrow do
177
Scale.AsVector := VectorMake(ArrowSize*Sz/2, ArrowSize*Sz/2, ArrowSize*Sz);
178
Material.FrontProperties.Diffuse.AsWinColor := xTextColor;
180
Direction.AsVector := VectorXDir;
181
Position.AsVector := VectorPos;
184
with ViewForm.yArrow do
188
Scale.AsVector := VectorMake(ArrowSize*Sz/2, ArrowSize*Sz/2, ArrowSize*Sz);
189
Material.FrontProperties.Diffuse.AsWinColor := yTextColor;
191
Direction.AsVector := VectorYDir;
192
Position.AsVector := VectorPos;
198
procedure TEvaluateForm.dzdx_dzdyClick(Sender: TObject);
200
ViewData.dzdx_dyChecked := dzdx_dzdy.Checked;
201
ViewForm.xArrow.Visible := dzdx_dzdy.Checked;
202
ViewForm.yArrow.Visible := dzdx_dzdy.Checked;
207
procedure TEvaluateForm.BitBtn1Click(Sender: TObject);
212
procedure TEvaluateForm.EditArrowKeyPress(Sender: TObject; var Key: Char);
214
with Sender as TEdit do
215
if not CharInSet(Key, PosFloat) then Key := #0;
218
procedure TEvaluateForm.EditArrowKeyUp(Sender: TObject; var Key: Word;
225
w := StrToFloat(EditArrow.Text);
229
ViewData.ArrowSize := w;
234
procedure TEvaluateForm.EditCoordWidthKeyUp(Sender: TObject; var Key: Word;
241
w := StrToInt(EditCoordWidth.Text);
245
ViewData.CoordWidth := w;
246
ViewForm.xCoordLine.LineWidth := w;
247
ViewForm.yCoordLine.LineWidth := w;
248
ViewForm.zCoordLine.LineWidth := w;
252
procedure TEvaluateForm.IntPress(Sender: TObject; var Key: Char);
254
with Sender as TEdit do
255
if not CharInSet(Key, ['0'..'9', #8]) then Key := #0
258
procedure TEvaluateForm.ColorButtonClick(Sender: TObject);
260
if ColorDialog.Execute then
262
ViewData.CoordColor := ColorDialog.Color;
268
procedure TEvaluateForm.CoordinatesClick(Sender: TObject);
270
ViewData.CoordChecked := Coordinates.Checked;
272
with ViewData do ShowCoords(xEvaluate, yEvaluate, zValue*xyGrid.zScale,
273
CoordChecked, ToGridsChecked);
274
if DerivativesForm.Visible and not Coordinates.Checked then
276
ViewForm.AddXLine.Visible := False;
277
ViewForm.AddYLine.Visible := False;
278
ViewForm.AddZLine.Visible := False;
284
procedure TEvaluateForm.ToGridsClick(Sender: TObject);
286
ViewData.ToGridsChecked := ToGrids.Checked;
288
with ViewData do ShowCoords(xEvaluate, yEvaluate, zValue*xyGrid.zScale,
289
CoordChecked, ToGridsChecked);
293
procedure TEvaluateForm.ShowCoords(const x, y, z: TGLFloat; const c, t: Boolean);
297
if c then { show coords }
301
if t then { to grids }
303
Position.SetPoint(GLyzGrid.Position.x, y, z);
304
Nodes[0].X := x - GLyzGrid.Position.x;
308
Position.SetPoint(x - GLxyGrid.XSamplingScale.Step, y, z);
309
Nodes[0].X := 2*GLxyGrid.XSamplingScale.Step;
316
if t then { to grids }
318
Position.SetPoint(x, GLxzGrid.Position.y, z);
319
Nodes[0].Y := y - GLxzGrid.Position.y;
323
Position.SetPoint(x, y - GLxyGrid.YSamplingScale.Step, z);
324
Nodes[0].Y := 2*GLxyGrid.YSamplingScale.Step;
331
if t then { to grids }
333
Position.SetPoint(x, y, GLxyGrid.Position.z);
334
Nodes[0].Z := z - GLxyGrid.Position.z;
338
Position.SetPoint(x, y, z - GLxzGrid.ZSamplingScale.Step);
339
Nodes[0].Z := 2*GLxzGrid.ZSamplingScale.Step;
344
{ only after DerivativesForm.ApplyBtnClick if AddedAs.AddedAs = AddVolume }
345
if DerivativesForm.Visible then
347
case AddedData.AddedAs of
350
with AddXLine do { xCoord }
352
if t then { to grids }
354
Position.SetPoint(GLyzGrid.Position.x, y, dzdx*ViewData.xyGrid.zScale);
355
Nodes[0].AsVector := VectorMake(x - GLyzGrid.Position.x, 0, 0);
359
Position.SetPoint(x - GLxyGrid.XSamplingScale.Step, y, dzdx*ViewData.xyGrid.zScale);
360
Nodes[0].AsVector := VectorMake(2*GLxyGrid.XSamplingScale.Step, 0, 0);
365
with AddYLine do { yCoord }
367
if t then { to grids }
369
Position.SetPoint(x, GLxzGrid.Position.y, dzdx*ViewData.xyGrid.zScale);
370
Nodes[0].AsVector := VectorMake(0, y - GLxzGrid.Position.y, 0);
374
Position.SetPoint(x, y - GLxyGrid.YSamplingScale.Step, dzdx*ViewData.xyGrid.zScale);
375
Nodes[0].AsVector := VectorMake(0, 2*GLxyGrid.YSamplingScale.Step, 0);
380
with AddZLine do { zCoord }
382
if t then { to grids }
384
Position.SetPoint(x, y, GLxyGrid.Position.z);
385
Nodes[0].AsVector := VectorMake(0, 0, dzdx*ViewData.xyGrid.zScale - GLxyGrid.Position.z);
389
Position.SetPoint(x, y, dzdx*ViewData.xyGrid.zScale - GLxzGrid.ZSamplingScale.Step);
390
Nodes[0].AsVector := VectorMake(0, 0, 2*GLxzGrid.ZSamplingScale.Step);
399
with AddXLine do { xCoord }
401
if t then { to grids }
403
Position.SetPoint(GLyzGrid.Position.x, y, dzdy*ViewData.xyGrid.zScale);
404
Nodes[0].AsVector := VectorMake(x - GLyzGrid.Position.x, 0, 0);
408
Position.SetPoint(x - GLxyGrid.XSamplingScale.Step, y, dzdy*ViewData.xyGrid.zScale);
409
Nodes[0].AsVector := VectorMake(2*GLxyGrid.XSamplingScale.Step, 0, 0);
414
with AddYLine do { yCoord }
416
if t then { to grids }
418
Position.SetPoint(x, GLxzGrid.Position.y, dzdy*ViewData.xyGrid.zScale);
419
Nodes[0].AsVector := VectorMake(0, y - GLxzGrid.Position.y, 0);
423
Position.SetPoint(x, y - GLxyGrid.YSamplingScale.Step, dzdy*ViewData.xyGrid.zScale);
424
Nodes[0].AsVector := VectorMake(0, 2*GLxyGrid.YSamplingScale.Step, 0);
429
with AddZLine do { zCoord }
431
if t then { to grids }
433
Position.SetPoint(x, y, GLxyGrid.Position.z);
434
Nodes[0].AsVector := VectorMake(0, 0, dzdy*ViewData.xyGrid.zScale - GLxyGrid.Position.z);
438
Position.SetPoint(x, y, dzdy*ViewData.xyGrid.zScale - GLxzGrid.ZSamplingScale.Step);
439
Nodes[0].AsVector := VectorMake(0, 0, 2*GLxzGrid.ZSamplingScale.Step);
448
AddXLine.Visible := False;
449
AddYLine.Visible := False;
450
AddZLine.Visible := False;
452
end; { case AddedData.AddedAs of... }
453
end; { if DerivativesForm.Visible then... }
454
end { if c then show coords }
456
begin { coordinate lines not visible }
457
xCoordLine.Visible := False;
458
yCoordLine.Visible := False;
459
zCoordLine.Visible := False;
465
EditArrow.Text := FloatToStr(ArrowSize);
466
EditCoordWidth.Text := IntToStr(CoordWidth);
467
ViewForm.xCoordLine.LineWidth := CoordWidth;
468
ViewForm.yCoordLine.LineWidth := CoordWidth;
469
ViewForm.zCoordLine.LineWidth := CoordWidth;
473
procedure TEvaluateForm.MenuClick(Sender: TObject);
475
if CurrentTag <> TMenuItem(Sender).Tag then
478
0:Slope1.Checked := False;
479
1:Degree1.Checked := False;
480
2:Radian1.Checked := False;
482
with Sender as TMenuItem do
491
procedure TEvaluateForm.UpdateEvaluate;
494
with ViewData do ShowCoords(xEvaluate, yEvaluate, zValue*xyGrid.zScale,
495
CoordChecked, ToGridsChecked);
498
procedure TEvaluateForm.UpdateCoords;
502
with xCoordLine do LineColor.AsWinColor := ViewData.CoordColor;
503
with yCoordLine do LineColor.AsWinColor := ViewData.CoordColor;
504
with zCoordLine do LineColor.AsWinColor := ViewData.CoordColor;