8
SysUtils, Variants, Classes, Graphics, Controls, Forms,
9
Dialogs, StdCtrls, CheckLst, Buttons, ComCtrls, Menus, uGlobal;
12
TFunctionsForm = class(TForm)
32
AddButton: TSpeedButton;
33
DeleteButton: TSpeedButton;
34
CheckListBox: TCheckListBox;
43
SaveDialog: TSaveDialog;
44
OpenDialog: TOpenDialog;
46
ModeComboBox: TComboBox;
47
StyleComboBox: TComboBox;
51
UpButton: TSpeedButton;
52
DownButton: TSpeedButton;
54
GridValues: TSpeedButton;
57
procedure FormDestroy(Sender: TObject);
58
procedure FloatKeyPress(Sender: TObject; var Key: Char);
59
procedure fxyKeyPress(Sender: TObject; var Key: Char);
60
procedure EditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
62
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
63
procedure FormClose(Sender: TObject; var Action: TCloseAction);
64
procedure AddButtonClick(Sender: TObject);
65
procedure SaveClick(Sender: TObject);
66
procedure SaveAsClick(Sender: TObject);
67
procedure CheckListBoxClick(Sender: TObject);
68
procedure DeleteButtonClick(Sender: TObject);
69
procedure Open1Click(Sender: TObject);
70
procedure Exit1Click(Sender: TObject);
71
procedure New1Click(Sender: TObject);
72
procedure zLimitCBClick(Sender: TObject);
73
procedure ModeComboBoxChange(Sender: TObject);
74
procedure StyleComboBoxChange(Sender: TObject);
75
procedure ApplyBtnClick(Sender: TObject);
76
procedure EditfxyClick(Sender: TObject);
77
procedure CheckListBoxClickCheck(Sender: TObject);
78
procedure EditdXKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
79
procedure EditdYKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
80
procedure EditMinXKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
81
procedure EditMaxXKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
82
procedure EditMinYKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
83
procedure EditMaxYKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
84
procedure EditMinZKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
85
procedure EditMaxZKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
86
procedure EditfxyKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
87
procedure CentreClick(Sender: TObject);
88
procedure UpButtonClick(Sender: TObject);
89
procedure DownButtonClick(Sender: TObject);
90
procedure FormCreate(Sender: TObject);
91
procedure zCapCBClick(Sender: TObject);
92
procedure GridValuesClick(Sender: TObject);
93
procedure PositiveKeyPress(Sender: TObject; var Key: Char);
94
procedure EditNoteClick(Sender: TObject);
95
procedure EditNoteKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
98
{ Private declarations }
100
TooManyPoints: integer;
101
function ReadData(const FName: TFileName): Boolean;
102
procedure OpenSelectedFile(Sender: TObject; FName: TFileName);
103
procedure WriteData(const FName: TFileName);
104
function DefaultPlotData: TPlotData;
105
function DefaultViewData: TViewData;
106
function DefaultAddedData: TAddedData;
107
procedure ShowData(Sender: TObject);
108
procedure AddNewPlot;
109
procedure CountzPoints;
110
procedure UpdateTPlotDataObject;
111
procedure AddRecent(const f: TFileName);
113
{ Public declarations }
114
procedure ReadAndShowInitialData;
115
procedure OpenRecentFile(FName: TFileName);
119
FunctionsForm: TFunctionsForm;
124
OpenGLTokens, Math, GLVectorGeometry, Main, uParser, GridOptions, GLColor,
125
Evaluate, GLVectorTypes, CoordOptions, DerivativeOptions, GridColors,
130
procedure TFunctionsForm.AddButtonClick(Sender: TObject);
135
procedure TFunctionsForm.EditdXKeyUp(Sender: TObject; var Key: Word;
142
x := StrToFloat(EditdX.Text);
147
ApplyBtn.Visible := True;
148
UpdateTPlotDataObject;
152
procedure TFunctionsForm.PositiveKeyPress(Sender: TObject; var Key: Char);
154
with Sender as TEdit do
155
if not CharInSet(Key, ['+', '0'..'9', '.', #8]) then Key := #0;
158
procedure TFunctionsForm.EditdYKeyUp(Sender: TObject; var Key: Word;
165
y := StrToFloat(EditdY.Text);
170
ApplyBtn.Visible := True;
171
UpdateTPlotDataObject;
175
procedure TFunctionsForm.EditfxyClick(Sender: TObject);
177
ViewForm.MousePoint.X := Maxint;
180
procedure TFunctionsForm.EditfxyKeyUp(Sender: TObject; var Key: Word;
188
PlotData.txtStr := Editfxy.Text;
189
PlotData.fxyStr := ScanText(Editfxy.Text);
190
ParseAndEvaluate(PlotData.fxyStr, e);
192
with CheckListBox do if (Count > 0) and (ItemIndex > -1)
193
then Items[ItemIndex] := PlotData.txtStr;
194
ApplyBtn.Visible := e = 0;
195
UpdateTPlotDataObject;
199
procedure TFunctionsForm.EditKeyDown(Sender: TObject; var Key: Word;
202
if (Key = VK_DELETE) or (Key = VK_BACK) then ApplyBtn.Visible := True;
205
procedure TFunctionsForm.fxyKeyPress(Sender: TObject; var Key: Char);
207
with Sender as TEdit do
209
if not CharInSet(UpCase(Key), ParseSet) then
214
if Key = '`' then Key := #176;
218
procedure TFunctionsForm.GridValuesClick(Sender: TObject);
223
with GridOptionsForm do
224
DoApply := xyLock.Checked and zLock.Checked and MinLock.Checked;
228
with ViewData.xyGrid.xRange do
230
EditMinX.Text := FloatToStrF(Minimum, ffGeneral, 7, 4);
231
PlotData.xMin := Minimum;
232
EditMaxX.Text := FloatToStrF(Maximum, ffGeneral, 7, 4);
233
PlotData.xMax := Maximum;
236
with ViewData.xyGrid.yRange do
238
EditMinY.Text := FloatToStrF(Minimum, ffGeneral, 7, 4);
239
PlotData.yMin := Minimum;
240
EditMaxY.Text := FloatToStrF(Maximum, ffGeneral, 7, 4);
241
PlotData.yMax := Maximum;
244
with ViewData.xzGrid.zRange do
246
EditMinZ.Text := FloatToStrF(Minimum, ffGeneral, 7, 4);
247
PlotData.zMin := Minimum;
248
EditMaxZ.Text := FloatToStrF(Maximum, ffGeneral, 7, 4);
249
PlotData.zMax := Maximum;
251
ApplyBtnClick(Sender);
255
procedure TFunctionsForm.ModeComboBoxChange(Sender: TObject);
257
PlotData.ViewMode := TViewMode(ModeComboBox.ItemIndex);
258
UpdateTPlotDataObject;
259
ApplyBtnClick(Sender);
262
procedure TFunctionsForm.New1Click(Sender: TObject);
268
if Altered or GridColorsAltered or DerivativeAltered then
269
case MessageDlg('The current graph''s data has been altered.'+
270
#13#10'Do you wish to save the alterations ?', mtConfirmation,
271
[mbYes, mbNo, mbCancel], 0) of
272
mrYes:SaveClick(Sender);
275
s := DataPath + GraphFName; { save original FName }
276
if s <> GraphFName then AddRecent(s);
279
for i := 0 to Items.Count -1 do Items.Objects[i].Free;
283
GraphFName := NewFName;
284
Caption := GraphFName;
285
ViewForm.Caption := GraphFName;
286
GridOptionsForm.Caption := GraphFName;
287
EvaluateForm.Caption := GraphFName;
288
CoordsForm.Caption := GraphFName;
292
ViewData := DefaultViewData;
293
PlotData := DefaultPlotData;
294
AddedData := DefaultAddedData;
296
if GridColorsForm.Visible then GridColorsForm.Close;
297
if PlotColorsForm.Visible then PlotColorsForm.Close;
298
if DerivativesForm.Visible then DerivativesForm.Close;
299
ApplyBtnClick(Sender);
302
AddItem(PlotData.txtStr, TPlotDataObject.Create(PlotData));
303
ItemIndex := Count -1;
304
Checked[ItemIndex] := True;
306
ViewForm.TargetCube.Position.SetPoint(0, 0, 0);
310
procedure TFunctionsForm.Open1Click(Sender: TObject);
316
if DerivativesForm.Visible then DerivativesForm.Close;
317
if GridColorsForm.Visible then GridColorsForm.ShowGridColorData;
318
if PlotColorsForm.Visible then PlotColorsForm.ShowPlotColorData;
319
if Altered or GridColorsAltered or DerivativeAltered then
320
case MessageDlg('The current graph''s data has been altered.'+
321
#13#10'Do you wish to save the alterations ?', mtConfirmation,
322
[mbYes, mbNo, mbCancel], 0) of
323
mrYes: SaveClick(Sender);
328
GridColorsAltered := False;
329
DerivativeAltered := False;
336
InitialDir := DataPath;
339
s := DataPath + GraphFName; { save original FName }
340
DataPath := ExtractFilePath(FileName);
341
DataPath := IncludeTrailingPathDelimiter(DataPath);
342
ViewForm.MousePoint.X := Maxint;
343
GraphFName := ExtractFileName(FileName);
344
if s <> GraphFName then AddRecent(s);
347
for i := 0 to Items.Count -1 do Items.Objects[i].Free;
350
if ReadData(DataPath + GraphFName) then ShowData(Sender);
351
ApplyBtnClick(Sender);
353
GridColorsAltered := False;
354
DerivativeAltered := False;
355
if GridColorsForm.Visible then GridColorsForm.ShowGridColorData;
356
if PlotColorsForm.Visible then PlotColorsForm.ShowPlotColorData;
361
procedure TFunctionsForm.EditMaxXKeyUp(Sender: TObject; var Key: Word;
368
x := StrToFloat(EditMaxX.Text);
373
ApplyBtn.Visible := True;
374
UpdateTPlotDataObject;
378
procedure TFunctionsForm.EditMaxYKeyUp(Sender: TObject; var Key: Word;
385
y := StrToFloat(EditMaxY.Text);
390
ApplyBtn.Visible := True;
391
UpdateTPlotDataObject;
395
procedure TFunctionsForm.EditMaxZKeyUp(Sender: TObject; var Key: Word;
402
z := StrToFloat(EditMaxZ.Text);
407
ApplyBtn.Visible := True;
408
UpdateTPlotDataObject;
412
procedure TFunctionsForm.EditMinXKeyUp(Sender: TObject; var Key: Word;
419
x := StrToFloat(EditMinX.Text);
424
ApplyBtn.Visible := True;
425
UpdateTPlotDataObject;
429
procedure TFunctionsForm.EditMinYKeyUp(Sender: TObject; var Key: Word;
436
y := StrToFloat(EditMinY.Text);
441
ApplyBtn.Visible := True;
442
UpdateTPlotDataObject;
446
procedure TFunctionsForm.EditMinZKeyUp(Sender: TObject; var Key: Word;
453
z := StrToFloat(EditMinZ.Text);
458
ApplyBtn.Visible := True;
459
UpdateTPlotDataObject;
463
procedure TFunctionsForm.EditNoteClick(Sender: TObject);
465
ViewForm.MousePoint.X := Maxint;
468
procedure TFunctionsForm.EditNoteKeyUp(Sender: TObject; var Key: Word;
473
PlotData.NoteStr := EditNote.Text;
474
with CheckListBox do if (Count > 0) and (ItemIndex > -1)
475
then TPlotDataObject(Items.Objects[ItemIndex]).Data := PlotData;
480
procedure TFunctionsForm.Exit1Click(Sender: TObject);
482
ViewForm.Exit1Click(Sender);
485
procedure TFunctionsForm.FloatKeyPress(Sender: TObject; var Key: Char);
487
with Sender as TEdit do
488
if not CharInSet(Key, AnyFloat) then Key := #0;
491
procedure TFunctionsForm.FormClose(Sender: TObject; var Action: TCloseAction);
496
for i := 0 to CheckListBox.Items.Count -1 do
497
CheckListBox.Items.Objects[i].Free;
501
procedure TFunctionsForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
504
CanClose := not ViewForm.Visible;
507
procedure TFunctionsForm.FormCreate(Sender: TObject);
512
procedure TFunctionsForm.FormDestroy(Sender: TObject);
517
with CheckListBox do for i := 0 to Count -1 do Items.Objects[i].Free;
520
function TFunctionsForm.DefaultPlotData: TPlotData;
524
fxyStr := ''; { function string }
525
txtStr := ''; { txt -> fxy when scanned }
526
NoteStr := ''; { describe function }
527
xMin := -10.0; { x limits and increment }
530
yMin := -10.0; { y limits and increment }
533
zMin := -10.0; { z limits }
535
zLim := False; { false = z limits do not apply }
536
zCap := False; { above zLim values := NAN }
538
UpperColor := VectorMake(255, 0, 0, 1000);
539
LowerColor := VectorMake(0, 0, 255, 1000);
543
ViewMode := vmAmbient;
548
function TFunctionsForm.DefaultViewData: TViewData;
552
CameraCubeAt := VectorMake(0, 0, 0);
553
CameraAt := VectorMake(50, 50, 30);
555
LightAt := VectorMake(50, 50, 50);
557
BackColor := clActiveCaption;
621
CoordChecked := False;
622
ToGridsChecked := False;
623
dzdx_dyChecked := False;
626
CoordColor := clBlack;
628
BoxLnColor := clrBlack;
630
TextVisible := False;
631
TextFontN := 'Tahoma';
635
xTextColor := clBlack;
639
yTextColor := clBlack;
642
TextFontN := 'Tahoma'; { ViewForm.GLWinBitmapFont }
651
yTextColor := clGreen;
655
zTextColor := clBlue;
660
function TFunctionsForm.DefaultAddedData: TAddedData;
664
xMin := -10.0; { x limits and increment }
667
yMin := -10.0; { y limits and increment }
670
zMin := -10.0; { z limits }
672
zLim := False; { false = z limits do not apply }
673
zCap := False; { above zLim values := NAN }
675
UpperColor := VectorMake(255, 0, 0, 1000);
676
LowerColor := VectorMake(0, 0, 255, 1000);
680
ViewMode := vmAmbient;
684
AddLineColor := clBlack;
689
procedure TFunctionsForm.CountzPoints;
695
n := round((xMax - xMin + xInc)/xInc)*round((yMax - yMin + yInc)/yInc);
696
TooManyPoints := round(Log10(n));
697
case TooManyPoints of
698
0..2:ZCountLabel.Font.Color := clLime;
699
3:ZCountLabel.Font.Color := clTeal;
700
4:ZCountLabel.Font.Color := clGreen;
701
5:ZCountLabel.Font.Color := clBlue;
702
else ZCountLabel.Font.Color := clRed;
705
then ZCountLabel.Caption := 'Too many Points: ' + FloatToStrF(n, ffnumber, 8, 0)+' !'
706
else ZCountLabel.Caption := 'N° Points = ' + FloatToStrF(n, ffnumber, 8, 0);
709
procedure TFunctionsForm.UpdateTPlotDataObject;
712
TPlotDataObject(Items.Objects[ItemIndex]).Data := PlotData;
715
procedure TFunctionsForm.DeleteButtonClick(Sender: TObject);
720
if CheckListBox.Count > 1 then
725
with Items.Objects[i] as TPlotDataObject do Free;
727
if i > Count -1 then i := Count -1;
729
PlotData := TPlotDataObject(Items.Objects[ItemIndex]).Data;
730
DeleteButton.Enabled := Count > 1;
732
ApplyBtnClick(Sender);
736
procedure TFunctionsForm.DownButtonClick(Sender: TObject);
744
if i < Count -1 then Items.Move(i, i+1);
747
CheckListBoxClick(Sender);
751
function TFunctionsForm.ReadData(const FName: TFileName): Boolean;
752
function StrToVector(s: string): TVector;
759
t := Copy(s, 1, i -1);
760
Result.X := StrToFloat(t);
762
s := Copy(s, i +1, Length(s));
764
t := Copy(s, 1, i -1);
765
Result.Y := StrToFloat(t);
767
s := Copy(s, i +1, Length(s));
768
Result.Z := StrToFloat(s);
771
function StrToColor(s: string): TColorVector;
778
t := Copy(s, 1, i -1);
779
Result.X := StrToFloat(t);
781
s := Copy(s, i +1, Length(s));
783
t := Copy(s, 1, i -1);
784
Result.Y := StrToFloat(t);
786
s := Copy(s, i +1, Length(s));
788
t := Copy(s, 1, i -1);
789
Result.Z := StrToFloat(t);
791
s := Copy(s, i +1, Length(s));
792
Result.W := StrToFloat(s);
795
function StrToRange(s: string): TRange;
802
t := Copy(s, 1, i -1);
803
Result.Maximum := StrToFloat(t);
805
s := Copy(s, i +1, Length(s));
807
t := Copy(s, 1, i -1);
808
Result.Minimum := StrToFloat(t);
810
s := Copy(s, i +1, Length(s));
811
Result.Step := StrToFloat(s);
821
if FileExists(FName) then
823
AssignFile(f, FName);
832
t := Copy(s, 1, i -1);
833
s := Copy(s, i +1, Length(s));
839
1:CameraCubeAt := StrToVector(t);
840
2:CameraAt := StrToVector(t);
841
3:fLength := StrToFloat(t);
842
4:LightAt := StrToVector(t);
843
5:ViewDepth := StrToFloat(t);
844
6:BackColor := StrToInt(t);
846
7:xyGrid.Color := StrToColor(t);
847
8:xyGrid.xRange := StrToRange(t);
848
9:xyGrid.yRange := StrToRange(t);
849
10:xyGrid.zPosition := StrToFloat(t);
850
11:xyGrid.zScale := StrToFloat(t);
851
12:xyGrid.IsVisible := StrToBool(t);
852
13:xyGrid.IsChecked := StrToBool(t);
854
14:xzGrid.Color := StrToColor(t);
855
15:xzGrid.xRange := StrToRange(t);
856
16:xzGrid.zRange := StrToRange(t);
857
17:xzGrid.yPosition := StrToFloat(t);
858
18:xzGrid.IsVisible := StrToBool(t);
859
19:xzGrid.IsChecked := StrToBool(t);
861
20:yzGrid.Color := StrToColor(t);
862
21:yzGrid.yRange := StrToRange(t);
863
22:yzGrid.zRange := StrToRange(t);
864
23:yzGrid.xPosition := StrToFloat(t);
865
24:yzGrid.IsVisible := StrToBool(t);
866
25:yzGrid.IsChecked := StrToBool(t);
867
26:ViewForm.TargetCube.Position.AsVector := StrToVector(t);
869
27:xEvaluate := StrToFloat(t);
870
28:yEvaluate := StrToFloat(t);
871
29:CoordChecked := StrToBool(t);
872
30:ToGridsChecked := StrToBool(t);
873
31:dzdx_dyChecked := StrToBool(t);
874
32:BoxChecked := StrToBool(t);
875
33:CoordWidth := StrToInt(t);
876
34:CoordColor := StrToInt(t);
877
35:BoxLnWidth := StrToInt(t);
878
36:BoxLnColor := StrToColor(t);
879
37:TextVisible := StrToBool(t);
881
39:TextFontSz := StrToInt(t);
882
40:xPosYMax := StrToBool(t);
883
41:xPosZMax := StrToBool(t);
884
42:xTextColor := StrToInt(t);
885
43:yPosXMax := StrToBool(t);
886
44:yPosZMax := StrToBool(t);
887
45:yTextColor := StrToInt(t);
888
46:zPosXMax := StrToBool(t);
889
47:zPosYMax := StrToBool(t);
890
48:zTextColor := StrToInt(t);
891
49:ArrowSize := StrTofloat(t);
894
n := StrToInt(s); { number of functions }
895
for k := 0 to n -1 do
896
begin{ read each function's data }
903
t := Copy(s, 1, i -1);
904
s := Copy(s, i +1, Length(s));
913
4:xMin := StrToFloat(t);
914
5:xMax := StrToFloat(t);
915
6:xInc := StrToFloat(t);
916
7:yMin := StrToFloat(t);
917
8:yMax := StrToFloat(t);
918
9:yInc := StrToFloat(t);
919
10:zMin := StrToFloat(t);
920
11:zMax := StrToFloat(t);
921
12:zLim := StrToBool(t);
922
13:zcap := StrToBool(t);
923
14:UpperColor := StrToColor(t);
924
15:LowerColor := StrToColor(t);
925
16:ColorBlend := StrToFloat(t);
926
17:ColorMove := StrToFloat(t);
927
18:ViewMode := TViewMode(StrToInt(t));
928
19:fxyMode := TfxyMode(StrToInt(t));
933
AddItem(PlotData.txtStr, TPlotDataObject.Create(PlotData));
934
Checked[Count -1] := StrToBool(s);
944
t := Copy(s, 1, i -1);
945
s := Copy(s, i +1, Length(s));
950
1:xMin := StrToFloat(t);
951
2:xMax := StrToFloat(t);
952
3:xInc := StrToFloat(t);
953
4:yMin := StrToFloat(t);
954
5:yMax := StrToFloat(t);
955
6:yInc := StrToFloat(t);
956
7:zMin := StrToFloat(t);
957
8:zMax := StrToFloat(t);
958
9:zLim := StrToBool(t);
959
10:zcap := StrToBool(t);
960
11:UpperColor := StrToColor(t);
961
12:LowerColor := StrToColor(t);
962
13:ColorBlend := StrToFloat(t);
963
14:ColorMove := StrToFloat(t);
964
15:ViewMode := TViewMode(StrToInt(t));
965
16:fxyMode := TfxyMode(StrToInt(t));
966
17:AddLineWidth := StrToInt(t);
967
18:AddLineColor := StrToInt(t);
968
19:AddedAs := TAddedType(StrToInt(t));
973
MessageDlg('File Error! An Error has occurred'+
974
#13#10'when attempting to read "'+FName+'".',
981
CheckListBox.ItemIndex := CheckListBox.Count -1;
982
NewFile := not Result;
986
procedure TFunctionsForm.SaveClick(Sender: TObject);
988
if NewFile then SaveAsClick(Sender) else WriteData(DataPath + GraphFName);
991
procedure TFunctionsForm.SaveAsClick(Sender: TObject);
995
InitialDir := DataPath;
996
FileName := GraphFName;
999
GraphFName := ExtractFileName(FileName);
1000
DataPath := ExtractFilePath(FileName);
1001
DataPath := IncludeTrailingPathDelimiter(DataPath);
1002
WriteData(DataPath + GraphFName);
1005
Caption := GraphFName;
1006
ViewForm.Caption := GraphFName;
1007
GridOptionsForm.Caption := GraphFName;
1008
EvaluateForm.Caption := GraphFName;
1009
CoordsForm.Caption := GraphFName;
1012
procedure TFunctionsForm.WriteData(const FName: TFileName);
1013
function VectorToStr(v: TVector): string;
1015
Result := FloatToStr(v.X)+','+FloatToStr(v.Y)+','+FloatToStr(v.Z);
1018
function ColorToStr(c: TColorVector): string;
1021
FloatToStr(c.X)+','+FloatToStr(c.Y)+','+FloatToStr(c.Z)+','+FloatToStr(c.W);
1024
function RangetoStr(r: TRange): string;
1027
FloatToStr(r.Maximum)+','+FloatToStr(r.Minimum)+','+FloatTostr(r.Step);
1037
AssignFile(f, FName);
1039
Rewrite(f); { write tab delimited data }
1042
CameraCubeAt := ViewForm.CameraCube.Position.AsVector;
1043
CameraAt := ViewForm.Camera.Position.AsVector;
1044
fLength := ViewForm.Camera.FocalLength;
1045
LightAt := ViewForm.GLLight.Position.AsVector;
1046
ViewDepth := ViewForm.Camera.DepthOfView;
1047
BackColor := ViewForm.GLSViewer.Buffer.BackgroundColor;
1049
s := VectorToStr(CameraCubeAt)+#9+VectorToStr(CameraAt)+#9+
1050
FloatToStr(fLength)+#9+VectorToStr(LightAt)+#9+
1051
FloatToStr(ViewDepth)+#9+IntToStr(BackColor)+#9+
1053
ColorToStr(xyGrid.Color)+#9+
1054
RangeToStr(xyGrid.xRange)+#9+RangeToStr(xyGrid.yRange)+#9+
1055
FloatToStr(xyGrid.zPosition)+#9+FloatToStr(xyGrid.zScale)+#9+
1056
BoolToStr(xyGrid.IsVisible)+#9+BoolToStr(xyGrid.IsChecked)+#9+
1058
ColorToStr(xzGrid.Color)+#9+
1059
RangeToStr(xzGrid.xRange)+#9+RangeToStr(xzGrid.zRange)+#9+
1060
FloatToStr(xzGrid.yPosition)+#9+BoolToStr(xzGrid.IsVisible)+#9+
1061
BoolToStr(xzGrid.IsChecked)+#9+
1063
ColorToStr(yzGrid.Color)+#9+
1064
RangeToStr(yzGrid.yRange)+#9+RangeToStr(yzGrid.zRange)+#9+
1065
FloatToStr(yzGrid.xPosition)+#9+BoolToStr(yzGrid.IsVisible)+#9+
1066
BoolToStr(yzGrid.IsChecked)+#9+
1068
VectorToStr(ViewForm.TargetCube.Position.AsVector)+#9+
1070
FloatToStr(xEvaluate)+#9+FloatToStr(yEvaluate)+#9+
1071
BoolToStr(CoordChecked)+#9+BoolToStr(ToGridsChecked)+#9+
1072
BoolToStr(dzdx_dyChecked)+#9+BoolToStr(BoxChecked)+#9+
1073
IntToStr(CoordWidth)+#9+IntToStr(CoordColor)+#9+
1074
IntToStr(BoxLnWidth)+#9+ColorToStr(BoxLnColor)+#9+
1075
BoolToStr(TextVisible)+#9+TextFontN+#9+IntToStr(TextFontSz)+#9+
1076
BoolToStr(xPosYMax)+#9+BoolToStr(xPosZMax)+#9+IntToStr(xTextColor)+#9+
1077
BoolToStr(yPosXMax)+#9+BoolToStr(yPosZMax)+#9+IntToStr(yTextColor)+#9+
1078
BoolToStr(zPosXMax)+#9+BoolToStr(zPosYMax)+#9+IntToStr(zTextColor)+#9+
1079
FloatToStr(ArrowSize)+#9+
1080
IntToStr(CheckListBox.Count); { number of functions }
1084
for i := 0 to CheckListBox.Count -1 do { each function }
1086
PlotData := TPlotDataObject(CheckListBox.Items.Objects[i]).Data;
1089
s := fxyStr+#9+txtStr+#9+NoteStr+#9+
1090
FloatToStr(xMin)+#9+FloatToStr(xMax)+#9+FloatToStr(xInc)+#9+
1091
FloatToStr(yMin)+#9+FloatToStr(yMax)+#9+FloatToStr(yInc)+#9+
1092
FloatToStr(zMin)+#9+FloatToStr(zMax)+#9+BoolToStr(zLim)+#9+
1093
BoolToStr(zCap)+#9+ColorToStr(UpperColor)+#9+ColorToStr(LowerColor)+#9+
1094
FloatToStr(ColorBlend)+#9+FloatToStr(ColorMove)+#9+IntToStr(Ord(ViewMode))+#9+
1095
IntToStr(Ord(fxyMode))+#9+BoolToStr(CheckListBox.Checked[i]);
1102
s := FloatToStr(xMin)+#9+FloatToStr(xMax)+#9+FloatToStr(xInc)+#9+
1103
FloatToStr(yMin)+#9+FloatToStr(yMax)+#9+FloatToStr(yInc)+#9+
1104
FloatToStr(zMin)+#9+FloatToStr(zMax)+#9+BoolToStr(zLim)+#9+
1105
BoolToStr(zCap)+#9+ColorToStr(UpperColor)+#9+ColorToStr(LowerColor)+#9+
1106
FloatToStr(ColorBlend)+#9+FloatToStr(ColorMove)+#9+IntToStr(Ord(ViewMode))+#9+
1107
IntToStr(Ord(fxyMode))+#9+IntToStr(AddLineWidth)+#9+IntToStr(AddLineColor)+#9+
1108
IntToStr(Ord(AddedAs));
1116
MessageDlg('File Error! An Error has occurred'+
1117
#13#10'when attempting to write to "'+GraphFName+'".',
1118
mtError, [mbOK], 0);
1122
Layout.CurrentGraphFName := GraphFName;
1125
procedure TFunctionsForm.zCapCBClick(Sender: TObject);
1127
PlotData.zCap := zCapCB.Checked;
1128
UpdateTPlotDataObject;
1129
Applybtn.Visible := True;
1132
procedure TFunctionsForm.zLimitCBClick(Sender: TObject);
1134
PlotData.zLim := zLimitCB.Checked;
1135
UpdateTPlotDataObject;
1136
Applybtn.Visible := True;
1139
procedure TFunctionsForm.ShowData(Sender: TObject);
1143
if not(Sender is TCheckListBox) then
1145
ViewForm.CameraCube.Position.AsVector := CameraCubeAt;
1146
ViewForm.Camera.Position.AsVector := CameraAt;
1147
ViewForm.Camera.FocalLength := fLength;
1148
ViewForm.GLLight.Position.AsVector := LightAt;
1149
ViewForm.Camera.DepthOfView := ViewDepth;
1150
ViewForm.GLSViewer.Buffer.BackgroundColor := BackColor;
1153
GridOptionsForm.EditViewDepth.Text := FloatToStrF(ViewDepth, ffGeneral, 7, 4);
1156
GridOptionsForm.EditxyGridMinx.Text := FloatToStrF(xyGrid.xRange.Minimum, ffGeneral, 7, 4);
1157
ViewForm.GLxyGrid.XSamplingScale.Min := xyGrid.xRange.Minimum;
1158
GridOptionsForm.EditxyGridMiny.Text := FloatToStrF(xyGrid.yRange.Minimum, ffGeneral, 7, 4);
1159
ViewForm.GLxyGrid.YSamplingScale.Min := xyGrid.yRange.Minimum;
1161
GridOptionsForm.EditxyGridMaxx.Text := FloatToStrF(xyGrid.xRange.Maximum, ffGeneral, 7, 4);
1162
ViewForm.GLxyGrid.XSamplingScale.Max := xyGrid.xRange.Maximum;
1163
GridOptionsForm.EditxyGridMaxy.Text := FloatToStrF(xyGrid.yRange.Maximum, ffGeneral, 7, 4);
1164
ViewForm.GLxyGrid.YSamplingScale.Max := xyGrid.yRange.Maximum;
1166
GridOptionsForm.EditxyGridStpx.Text := FloatToStrF(xyGrid.xRange.Step, ffGeneral, 7, 4);
1167
ViewForm.GLxyGrid.XSamplingScale.Step := xyGrid.xRange.Step;
1168
GridOptionsForm.EditxyGridStpy.Text := FloatToStrF(xyGrid.yRange.Step, ffGeneral, 7, 4);
1169
ViewForm.GLxyGrid.YSamplingScale.Step := xyGrid.yRange.Step;
1171
GridOptionsForm.EditxyGridPosz.Text := FloatToStrF(xyGrid.zPosition, ffGeneral, 7, 4);
1172
ViewForm.GLxyGrid.Position.Z := xyGrid.zPosition*xyGrid.zScale;
1174
GridOptionsForm.EditzScale.Text := FloatToStrF(xyGrid.zScale, ffGeneral, 7, 4);
1175
ViewForm.GLxzGrid.Scale.Z := xyGrid.zScale;
1176
ViewForm.GLyzGrid.Scale.Z := xyGrid.zScale;
1178
ViewForm.GLxyGrid.LineColor.SetColor(xyGrid.Color.X, xyGrid.Color.Y,
1179
xyGrid.Color.Z, xyGrid.Color.W);
1182
GridOptionsForm.EditxzGridMinx.Text := FloatToStrF(xzGrid.xRange.Minimum, ffGeneral, 7, 4);
1183
ViewForm.GLxzGrid.XSamplingScale.Min := xzGrid.xRange.Minimum;
1184
GridOptionsForm.EditxzGridMinz.Text := FloatToStrF(xzGrid.zRange.Minimum, ffGeneral, 7, 4);
1185
ViewForm.GLxzGrid.ZSamplingScale.Min := xzGrid.zRange.Minimum;
1187
GridOptionsForm.EditxzGridMaxx.Text := FloatToStrF(xzGrid.xRange.Maximum, ffGeneral, 7, 4);
1188
ViewForm.GLxzGrid.XSamplingScale.Max := xzGrid.xRange.Maximum;
1189
GridOptionsForm.EditxzGridMaxz.Text := FloatToStrF(xzGrid.zRange.Maximum, ffGeneral, 7, 4);
1190
ViewForm.GLxzGrid.ZSamplingScale.Max := xzGrid.zRange.Maximum;
1192
GridOptionsForm.EditxzGridStpx.Text := FloatToStrF(xzGrid.xRange.Step, ffGeneral, 7, 4);
1193
ViewForm.GLxzGrid.XSamplingScale.Step := xzGrid.xRange.Step;
1194
GridOptionsForm.EditxzGridStpz.Text := FloatToStrF(xzGrid.zRange.Step, ffGeneral, 7, 4);
1195
ViewForm.GLxzGrid.ZSamplingScale.Step := xzGrid.zRange.Step;
1197
GridOptionsForm.EditxzGridPosy.Text := FloatToStrF(xzGrid.yPosition, ffGeneral, 7, 4);
1198
ViewForm.GLxzGrid.Position.Y := xzGrid.yPosition;
1200
ViewForm.GLxzGrid.LineColor.SetColor(xzGrid.Color.X, xzGrid.Color.Y,
1201
xzGrid.Color.Z, xzGrid.Color.W);
1204
GridOptionsForm.EdityzGridMiny.Text := FloatToStrF(yzGrid.yRange.Minimum, ffGeneral, 7, 4);
1205
ViewForm.GLyzGrid.YSamplingScale.Min := yzGrid.yRange.Minimum;
1206
GridOptionsForm.EdityzGridMinz.Text := FloatToStrF(yzGrid.zRange.Minimum, ffGeneral, 7, 4);
1207
ViewForm.GLyzGrid.ZSamplingScale.Min := yzGrid.zRange.Minimum;
1209
GridOptionsForm.EdityzGridMaxy.Text := FloatToStrF(yzGrid.yRange.Maximum, ffGeneral, 7, 4);
1210
ViewForm.GLyzGrid.YSamplingScale.Max := yzGrid.yRange.Maximum;
1211
GridOptionsForm.EdityzGridMaxz.Text := FloatToStrF(yzGrid.zRange.Maximum, ffGeneral, 7, 4);
1212
ViewForm.GLyzGrid.ZSamplingScale.Max := yzGrid.zRange.Maximum;
1214
GridOptionsForm.EdityzGridStpy.Text := FloatToStrF(yzGrid.yRange.Step, ffGeneral, 7, 4);
1215
ViewForm.GLyzGrid.YSamplingScale.Step := yzGrid.yRange.Step;
1216
GridOptionsForm.EdityzGridStpz.Text := FloatToStrF(yzGrid.zRange.Step, ffGeneral, 7, 4);
1217
ViewForm.GLyzGrid.ZSamplingScale.Step := yzGrid.zRange.Step;
1219
GridOptionsForm.EdityzGridPosx.Text := FloatToStrF(yzGrid.xPosition, ffGeneral, 7, 4);
1220
ViewForm.GLyzGrid.Position.X := yzGrid.xPosition;
1222
ViewForm.GLyzGrid.LineColor.SetColor(yzGrid.Color.X, yzGrid.Color.Y,
1223
yzGrid.Color.Z, yzGrid.Color.W);
1225
ViewForm.BoxLine1.LineColor.SetColor(BoxLnColor.X, BoxLnColor.Y,
1226
BoxLnColor.Z, BoxLnColor.W);
1227
ViewForm.BoxLine2.LineColor := ViewForm.BoxLine1.LineColor;
1228
ViewForm.BoxLine3.LineColor := ViewForm.BoxLine1.LineColor;
1229
ViewForm.BoxLine4.LineColor := ViewForm.BoxLine1.LineColor;
1231
GridOptionsForm.xyGridCB.Checked := xyGrid.IsVisible;
1232
GridOptionsForm.xyLock.Checked := xyGrid.IsChecked;
1233
ViewForm.GLxyGrid.Visible := xyGrid.IsVisible;
1235
GridOptionsForm.xzGridCB.Checked := xzGrid.IsVisible;
1236
GridOptionsForm.zLock.Checked := xzGrid.IsChecked;
1237
ViewForm.GLxzGrid.Visible := xzGrid.IsVisible;
1239
GridOptionsForm.yzGridCB.Checked := yzGrid.IsVisible;
1240
GridOptionsForm.MinLock.Checked := yzGrid.IsChecked;
1241
ViewForm.GLyzGrid.Visible := yzGrid.IsVisible;
1243
GridOptionsForm.EditzScale.Text := FloatToStrF(xyGrid.zScale, ffGeneral, 7, 4);
1244
ViewForm.GLxzGrid.Scale.Z := xyGrid.zScale;
1245
ViewForm.GLyzGrid.Scale.Z := xyGrid.zScale;
1247
GridOptionsForm.BoxOutlineCB.Checked := BoxChecked;
1248
GridOptionsForm.EditBoxLnWidth.Text := IntToStr(BoxLnWidth);
1249
GridOptionsForm.DrawOutline(BoxChecked);
1251
EvaluateForm.EditX.Text := FloatToStrF(xEvaluate, ffGeneral, 7, 4);
1252
EvaluateForm.EditY.Text := FloatToStrF(yEvaluate, ffGeneral, 7, 4);
1253
EvaluateForm.EditZ.Text := '';
1254
EvaluateForm.EditCoordWidth.Text := IntToStr(CoordWidth);
1255
EvaluateForm.Coordinates.Checked := CoordChecked;
1256
EvaluateForm.ToGrids.Checked := ToGridsChecked;
1257
EValuateForm.dzdx_dzdy.Checked := dzdx_dyChecked;
1258
EvaluateForm.ColorDialog.Color := CoordColor;
1259
EvaluateForm.UpdateCoords;
1260
EvaluateForm.UpdateEvaluate;
1262
CoordsForm.ShowCoordsCB.Checked := TextVisible;
1263
CoordsForm.FontButton.Caption := 'Font:'+' '+TextFontN+' '+IntToStr(TextFontSz);
1264
ViewForm.GLWinBmpFont.Font.Name := TextFontN;
1265
ViewForm.GLWinBmpFont.Font.Size := TextFontSz;
1266
CoordsForm.xMaxYCB.Checked := xPosYMax;
1267
CoordsForm.xMaxZCB.Checked := xPosZMax;
1269
CoordsForm.yMaxXCB.Checked := yPosXMax;
1270
CoordsForm.yMaxZCB.Checked := yPosZMax;
1272
CoordsForm.zMaxYCB.Checked := zPosYMax;
1273
CoordsForm.zMaxXCB.Checked := zPosXMax;
1275
CoordsForm.UpdateCoordText;
1280
Editfxy.Text := txtStr;
1281
EditNote.Text := NoteStr;
1283
EditMinX.Text := FloatToStrF(xMin, ffGeneral, 7, 4);
1284
EditMaxX.Text := FloatToStrF(xMax, ffGeneral, 7, 4);
1285
EditdX.Text := FloatToStrF(xInc, ffGeneral, 7, 4);
1287
EditMinY.Text := FloatToStrF(yMin, ffGeneral, 7, 4);
1288
EditMaxY.Text := FloatToStrF(yMax, ffGeneral, 7, 4);
1289
EditdY.Text := FloatToStrF(yInc, ffGeneral, 7, 4);
1291
EditMinZ.Text := FloatToStrF(zMin, ffGeneral, 7, 4);
1292
EditMaxZ.Text := FloatToStrF(zMax, ffGeneral, 7, 4);
1293
zLimitCB.Checked := zLim;
1294
zCapCB.Checked := zCap;
1296
ModeComboBox.ItemIndex := Ord(ViewMode);
1297
StyleComboBox.ItemIndex := Ord(fxyMode);
1299
Caption := GraphFName;
1300
ViewForm.Caption := GraphFName;
1301
GridOptionsForm.Caption := GraphFName;
1302
EvaluateForm.Caption := GraphFName;
1303
CoordsForm.Caption := GraphFName;
1307
procedure TFunctionsForm.StyleComboBoxChange(Sender: TObject);
1309
PlotData.fxyMode := TfxyMode(StyleComboBox.ItemIndex);
1310
UpdateTPlotDataObject;
1311
ApplyBtnClick(Sender);
1314
procedure TFunctionsForm.UpButtonClick(Sender: TObject);
1319
with CheckListBox do
1322
if i > 0 then Items.Move(i, i-1);
1323
if i > 1 then ItemIndex := i-1 else ItemIndex := 0;
1325
CheckListBoxClick(Sender);
1329
procedure TFunctionsForm.AddNewPlot;
1331
with CheckListBox do
1333
AddItem(PlotData.txtStr, TPlotDataObject.Create(PlotData));
1334
ItemIndex := Count -1;
1335
Checked[ItemIndex] := True; { initially this item is checked }
1338
Editfxy.SelLength := 0;
1341
procedure TFunctionsForm.ApplyBtnClick(Sender: TObject);
1347
if TooManyPoints > 6 then Exit;
1351
if xMin > xMax then { swap }
1357
EditMinX.Text := EditMaxX.Text;
1359
UpdateTPlotDataObject;
1361
if yMin > yMax then { swap }
1367
EditMinY.Text := EditMaxY.Text;
1369
UpdateTPlotDataObject;
1373
AddedData.AddedAs := AddNone;
1375
ViewForm.UpdatePlot;
1376
EvaluateForm.UpdateEvaluate;
1377
ApplyBtn.Visible := False;
1381
procedure TFunctionsForm.CentreClick(Sender: TObject);
1388
MousePoint.X := Maxint;
1389
x := PlotData.xMax + PlotData.xMin;
1390
y := PlotData.yMax + PlotData.yMin;
1391
z := PlotData.zMax + PlotData.zMin;
1392
TargetCube.Position.SetPoint(x/2, y/2, z/2);
1395
ViewForm.ShowDisplacement;
1398
procedure TFunctionsForm.CheckListBoxClick(Sender: TObject);
1400
with CheckListBox do
1402
PlotData := TPlotDataObject(Items.Objects[ItemIndex]).Data;
1403
if Checked[ItemIndex] then EvaluateForm.UpdateEvaluate;
1406
if PlotColorsForm.Visible then PlotColorsForm.ShowPlotColorData;
1407
if DerivativesForm.Visible then DerivativesForm.ApplyBtn.Visible := True;
1410
procedure TFunctionsForm.CheckListBoxClickCheck(Sender: TObject);
1412
ApplyBtn.Visible := True;
1415
procedure TFunctionsForm.ReadAndShowInitialData;
1417
if not ReadData(DataPath + GraphFName) then
1419
GraphFName := NewFName;
1421
ViewData := DefaultViewData;
1422
PlotData := DefaultPlotData;
1423
AddedData := DefaultAddedData;
1424
with CheckListBox do
1426
AddItem(PlotData.txtStr, TPlotDataObject.Create(PlotData));
1427
ItemIndex := Count -1;
1428
Checked[ItemIndex] := True; { initially this item is checked }
1430
ViewForm.TargetCube.Position.SetPoint(0, 0, 0);
1433
Caption := GraphFName;
1437
procedure TFunctionsForm.OpenRecentFile(FName: TFileName);
1442
if DerivativesForm.Visible then DerivativesForm.Close;
1443
if FileExists(FName) then
1445
if Altered or GridColorsAltered then
1446
case MessageDlg('The current graph''s data has been altered.'+
1447
#13#10'Do you wish to save the alterations ?', mtConfirmation,
1448
[mbYes, mbNo, mbCancel], 0) of
1449
mrYes:SaveClick(Self);
1454
GridColorsAltered := False;
1455
DerivativeAltered := False;
1460
DataPath := ExtractFilePath(FName);
1461
DataPath := IncludeTrailingPathDelimiter(DataPath);
1462
ViewForm.MousePoint.X := Maxint;
1463
GraphFName := ExtractFileName(FName);
1465
with CheckListBox do
1467
for i := 0 to Items.Count -1 do Items.Objects[i].Free;
1471
if ReadData(FName) then ShowData(Self);
1472
if GridColorsForm.Visible then GridColorsForm.ShowGridColorData;
1473
if PlotColorsForm.Visible then PlotColorsForm.ShowPlotColorData;
1475
ApplyBtnClick(Self);
1477
GridColorsAltered := False;
1478
DerivativeAltered := False;
1480
else MessageDlg('The file '+FName+' does not exist!', mtError, [mbOK], 0);
1483
procedure TFunctionsForm.AddRecent(const f: TFileName);
1489
with ViewForm.Recent1 do
1493
while (i < Count) and not Found do
1495
Found := Items[i].Caption = DataPath + GraphFName;
1498
if Found then Delete(i -1);
1499
Insert(0, TMenuItem.Create(Self));
1500
Items[0].Caption := DataPath + GraphFName;
1501
Items[0].OnClick := ViewForm.RecentFilesClick;
1502
if Count > 16 then Delete(Count -1);
1506
procedure TFunctionsForm.OpenSelectedFile(Sender: TObject; FName: TFileName);
1511
if FileExists(FName) then
1513
Screen.Cursor := crHourglass;
1514
with CheckListBox do
1516
for i := 0 to Items.Count -1 do Items.Objects[i].Free;
1520
GraphFName := ExtractFileName(FName);
1522
if ReadData(DataPath + GraphFName) then
1524
Caption := GraphFName;
1525
ViewForm.Caption := GraphFName;
1526
GridOptionsForm.Caption := GraphFName;
1530
{ NewFont needed to initialize GLWinFont.GetCharWidth
1531
if the font has been altered, which may or may not be the case,
1533
ViewForm.GLSViewer.Buffer.BackgroundColor := ViewData.BackColor;
1534
ViewForm.GLSViewer.Invalidate;
1536
Screen.Cursor := crDefault;
1540
MessageDlg('The file'+FName+
1541
#13#10'Could not be found.', mtError, [mbOK], 0);
1542
Screen.Cursor := crDefault;