Merge branch 'master' of git.liokor.com:KoroLion/FunctionImagingInPascal
This commit is contained in:
commit
1eebc384ee
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1,5 +1,11 @@
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
build/gui
|
||||||
|
build/function_imaging
|
||||||
|
build/multibrot_imaging
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*.ppu
|
*.ppu
|
||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
*.pdf
|
*.pdf
|
||||||
|
|
17
build.mac.sh
Executable file
17
build.mac.sh
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
rm ./build/multibrot_imaging
|
||||||
|
rm ./build/function_imaging
|
||||||
|
rm ./build/gui
|
||||||
|
|
||||||
|
cd ./src
|
||||||
|
fpc multibrot_imaging.pas
|
||||||
|
mv multibrot_imaging ../build/
|
||||||
|
fpc function_imaging.pas
|
||||||
|
mv function_imaging ../build/
|
||||||
|
rm *.o
|
||||||
|
rm *.ppu
|
||||||
|
|
||||||
|
cd ./gui
|
||||||
|
fpc gui.pas -Fu/usr/local/Cellar/fpc/3.0.4_1/lib/fpc/3.0.4/units/x86_64-darwin/fv
|
||||||
|
mv gui ../../build/
|
||||||
|
rm *.o
|
||||||
|
rm *.ppu
|
|
@ -14,7 +14,7 @@ type
|
||||||
centerX: string[64];
|
centerX: string[64];
|
||||||
centerY: string[64];
|
centerY: string[64];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PFnGenerateData = ^TFnGenerateData;
|
PFnGenerateData = ^TFnGenerateData;
|
||||||
TFnGenerateData = record
|
TFnGenerateData = record
|
||||||
path: string[128];
|
path: string[128];
|
||||||
|
@ -25,50 +25,50 @@ type
|
||||||
centerX: string[64];
|
centerX: string[64];
|
||||||
centerY: string[64];
|
centerY: string[64];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PGeneratorWindow = ^TGeneratorWindow;
|
PGeneratorWindow = ^TGeneratorWindow;
|
||||||
TGeneratorWindow = object(TDialog)
|
TGeneratorWindow = object(TDialog)
|
||||||
pGeneratingBtn: PButton;
|
pGeneratingBtn: PButton;
|
||||||
winRect: TRect;
|
winRect: TRect;
|
||||||
curY: integer;
|
curY: integer;
|
||||||
|
|
||||||
procedure addField(caption: string; maxLength: integer);
|
procedure addField(caption: string; maxLength: integer);
|
||||||
function addButton(caption: string; command: integer): PButton;
|
function addButton(caption: string; command: integer): PButton;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PMbGeneratorWindow = ^TMbGeneratorWindow;
|
PMbGeneratorWindow = ^TMbGeneratorWindow;
|
||||||
TMbGeneratorWindow = object(TGeneratorWindow)
|
TMbGeneratorWindow = object(TGeneratorWindow)
|
||||||
constructor Init;
|
constructor Init;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PFnGeneratorWindow = ^TFnGeneratorWindow;
|
PFnGeneratorWindow = ^TFnGeneratorWindow;
|
||||||
TFnGeneratorWindow = object(TGeneratorWindow)
|
TFnGeneratorWindow = object(TGeneratorWindow)
|
||||||
constructor Init;
|
constructor Init;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TMSApp = object(TApplication)
|
TMSApp = object(TApplication)
|
||||||
MbGeneratorWindow: PMbGeneratorWindow;
|
MbGeneratorWindow: PMbGeneratorWindow;
|
||||||
FnGeneratorWindow: PFnGeneratorWindow;
|
FnGeneratorWindow: PFnGeneratorWindow;
|
||||||
|
|
||||||
procedure InitStatusLine; virtual;
|
procedure InitStatusLine; virtual;
|
||||||
procedure InitMenuBar; virtual;
|
procedure InitMenuBar; virtual;
|
||||||
procedure HandleEvent(var Event: TEvent); virtual;
|
procedure HandleEvent(var Event: TEvent); virtual;
|
||||||
|
|
||||||
procedure NewMbWindow();
|
procedure NewMbWindow();
|
||||||
procedure NewFnWindow();
|
procedure NewFnWindow();
|
||||||
|
|
||||||
procedure GenerateMultibrotSetImage();
|
procedure GenerateMultibrotSetImage();
|
||||||
procedure GenerateFunctionImage();
|
procedure GenerateFunctionImage();
|
||||||
|
|
||||||
procedure ShowAbout();
|
procedure ShowAbout();
|
||||||
procedure ShowSuccess(fname: string; t: extended);
|
procedure ShowSuccess(fname: string; t: extended);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
MSApp: TMSApp;
|
MSApp: TMSApp;
|
||||||
MbGenerateData: TMbGenerateData;
|
MbGenerateData: TMbGenerateData;
|
||||||
FnGenerateData: TFnGenerateData;
|
FnGenerateData: TFnGenerateData;
|
||||||
|
|
||||||
procedure TMSApp.GenerateMultibrotSetImage();
|
procedure TMSApp.GenerateMultibrotSetImage();
|
||||||
var
|
var
|
||||||
s: AnsiString;
|
s: AnsiString;
|
||||||
|
@ -77,7 +77,7 @@ var
|
||||||
begin
|
begin
|
||||||
MbGeneratorWindow^.GetData(MbGenerateData);
|
MbGeneratorWindow^.GetData(MbGenerateData);
|
||||||
startTime := getTimestamp();
|
startTime := getTimestamp();
|
||||||
|
|
||||||
MbGeneratorWindow^.pGeneratingBtn^.show();
|
MbGeneratorWindow^.pGeneratingBtn^.show();
|
||||||
with MbGenerateData do begin
|
with MbGenerateData do begin
|
||||||
success := RunCommand('./multibrot_imaging', [
|
success := RunCommand('./multibrot_imaging', [
|
||||||
|
@ -91,14 +91,14 @@ begin
|
||||||
], s);
|
], s);
|
||||||
end;
|
end;
|
||||||
MbGeneratorWindow^.pGeneratingBtn^.hide();
|
MbGeneratorWindow^.pGeneratingBtn^.hide();
|
||||||
|
|
||||||
if (success) then begin
|
if (success) then begin
|
||||||
ShowSuccess(s, (getTimestamp() - startTime) / 1000);
|
ShowSuccess(s, (getTimestamp() - startTime) / 1000);
|
||||||
end else begin
|
end else begin
|
||||||
MessageBox(
|
MessageBox(
|
||||||
#3'Error'#13 +
|
#3'Error'#13 +
|
||||||
#3'Unable to execute generator!'#13,
|
#3'Unable to execute generator!'#13,
|
||||||
nil,
|
nil,
|
||||||
mfInformation or mfOkButton
|
mfInformation or mfOkButton
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
@ -112,7 +112,7 @@ var
|
||||||
begin
|
begin
|
||||||
FnGeneratorWindow^.GetData(FnGenerateData);
|
FnGeneratorWindow^.GetData(FnGenerateData);
|
||||||
startTime := getTimestamp();
|
startTime := getTimestamp();
|
||||||
|
|
||||||
FnGeneratorWindow^.pGeneratingBtn^.show();
|
FnGeneratorWindow^.pGeneratingBtn^.show();
|
||||||
with FnGenerateData do begin
|
with FnGenerateData do begin
|
||||||
success := RunCommand('./function_imaging', [
|
success := RunCommand('./function_imaging', [
|
||||||
|
@ -126,14 +126,14 @@ begin
|
||||||
], s);
|
], s);
|
||||||
end;
|
end;
|
||||||
FnGeneratorWindow^.pGeneratingBtn^.hide();
|
FnGeneratorWindow^.pGeneratingBtn^.hide();
|
||||||
|
|
||||||
if (success) then begin
|
if (success) then begin
|
||||||
ShowSuccess(s, (getTimestamp() - startTime) / 1000);
|
ShowSuccess(s, (getTimestamp() - startTime) / 1000);
|
||||||
end else begin
|
end else begin
|
||||||
MessageBox(
|
MessageBox(
|
||||||
#3'Error'#13 +
|
#3'Error'#13 +
|
||||||
#3'Unable to execute generator!'#13,
|
#3'Unable to execute generator!'#13,
|
||||||
nil,
|
nil,
|
||||||
mfInformation or mfOkButton
|
mfInformation or mfOkButton
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
@ -151,7 +151,7 @@ begin
|
||||||
Insert(il);
|
Insert(il);
|
||||||
r.assign(2, curY, 13, curY + 1);
|
r.assign(2, curY, 13, curY + 1);
|
||||||
Insert(New(PLabel, Init(r, caption, il)));
|
Insert(New(PLabel, Init(r, caption, il)));
|
||||||
|
|
||||||
curY := curY + 2;
|
curY := curY + 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -163,12 +163,12 @@ begin
|
||||||
r.assign(3, curY, winRect.b.x - 1, curY + 1);
|
r.assign(3, curY, winRect.b.x - 1, curY + 1);
|
||||||
pbtn := New(PButton, Init(r, caption, command, bfNormal));
|
pbtn := New(PButton, Init(r, caption, command, bfNormal));
|
||||||
Insert(pbtn);
|
Insert(pbtn);
|
||||||
|
|
||||||
curY := curY + 2;
|
curY := curY + 2;
|
||||||
|
|
||||||
addButton := pbtn;
|
addButton := pbtn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TMbGeneratorWindow.Init();
|
constructor TMbGeneratorWindow.Init();
|
||||||
var
|
var
|
||||||
r: TRect;
|
r: TRect;
|
||||||
|
@ -177,10 +177,10 @@ begin
|
||||||
inherited Init(r, 'Multibrot generator');
|
inherited Init(r, 'Multibrot generator');
|
||||||
Options := Options or ofCentered;
|
Options := Options or ofCentered;
|
||||||
HelpCtx := $F000;
|
HelpCtx := $F000;
|
||||||
|
|
||||||
winRect := r;
|
winRect := r;
|
||||||
curY := 2;
|
curY := 2;
|
||||||
|
|
||||||
with MbGenerateData do begin
|
with MbGenerateData do begin
|
||||||
path := './multibrot_images';
|
path := './multibrot_images';
|
||||||
width := '512';
|
width := '512';
|
||||||
|
@ -190,7 +190,7 @@ begin
|
||||||
centerX := '0';
|
centerX := '0';
|
||||||
centerY := '0';
|
centerY := '0';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addField('Path:', 128);
|
addField('Path:', 128);
|
||||||
addField('Width:', 16);
|
addField('Width:', 16);
|
||||||
addField('Height:', 16);
|
addField('Height:', 16);
|
||||||
|
@ -198,7 +198,7 @@ begin
|
||||||
addField('Zoom:', 64);
|
addField('Zoom:', 64);
|
||||||
addField('Center X:', 64);
|
addField('Center X:', 64);
|
||||||
addField('Center Y:', 64);
|
addField('Center Y:', 64);
|
||||||
|
|
||||||
addButton('Generate', cmMbGenerate);
|
addButton('Generate', cmMbGenerate);
|
||||||
curY := curY - 2;
|
curY := curY - 2;
|
||||||
pGeneratingBtn := addButton('Generating...', 0);
|
pGeneratingBtn := addButton('Generating...', 0);
|
||||||
|
@ -213,10 +213,10 @@ begin
|
||||||
inherited Init(r, 'Function generator');
|
inherited Init(r, 'Function generator');
|
||||||
Options := Options or ofCentered;
|
Options := Options or ofCentered;
|
||||||
HelpCtx := $F000;
|
HelpCtx := $F000;
|
||||||
|
|
||||||
winRect := r;
|
winRect := r;
|
||||||
curY := 2;
|
curY := 2;
|
||||||
|
|
||||||
with FnGenerateData do begin
|
with FnGenerateData do begin
|
||||||
path := './function_images';
|
path := './function_images';
|
||||||
width := '512';
|
width := '512';
|
||||||
|
@ -226,7 +226,7 @@ begin
|
||||||
centerX := '0';
|
centerX := '0';
|
||||||
centerY := '0';
|
centerY := '0';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addField('Path:', 128);
|
addField('Path:', 128);
|
||||||
addField('Width:', 16);
|
addField('Width:', 16);
|
||||||
addField('Height:', 16);
|
addField('Height:', 16);
|
||||||
|
@ -234,7 +234,7 @@ begin
|
||||||
addField('Zoom:', 64);
|
addField('Zoom:', 64);
|
||||||
addField('Center X:', 64);
|
addField('Center X:', 64);
|
||||||
addField('Center Y:', 64);
|
addField('Center Y:', 64);
|
||||||
|
|
||||||
addButton('Generate', cmFnGenerate);
|
addButton('Generate', cmFnGenerate);
|
||||||
curY := curY - 2;
|
curY := curY - 2;
|
||||||
pGeneratingBtn := addButton('Generating...', 0);
|
pGeneratingBtn := addButton('Generating...', 0);
|
||||||
|
@ -247,21 +247,21 @@ begin
|
||||||
FnGeneratorWindow^.SetData(FnGenerateData);
|
FnGeneratorWindow^.SetData(FnGenerateData);
|
||||||
InsertWindow(FnGeneratorWindow);
|
InsertWindow(FnGeneratorWindow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMSApp.NewMbWindow();
|
procedure TMSApp.NewMbWindow();
|
||||||
begin
|
begin
|
||||||
MbGeneratorWindow := New(PMbGeneratorWindow, Init);
|
MbGeneratorWindow := New(PMbGeneratorWindow, Init);
|
||||||
MbGeneratorWindow^.SetData(MbGenerateData);
|
MbGeneratorWindow^.SetData(MbGenerateData);
|
||||||
InsertWindow(MbGeneratorWindow);
|
InsertWindow(MbGeneratorWindow);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMSApp.ShowAbout();
|
procedure TMSApp.ShowAbout();
|
||||||
begin
|
begin
|
||||||
MessageBox(
|
MessageBox(
|
||||||
#3'Math images generator'#13 +
|
#3'Math images generator'#13 +
|
||||||
#3'Developed by Artem K.'#13 +
|
#3'Developed by Artem K.'#13 +
|
||||||
#3'MF BMSTU 2019 - 2020',
|
#3'MF BMSTU 2019 - 2020',
|
||||||
nil,
|
nil,
|
||||||
mfInformation or mfOkButton
|
mfInformation or mfOkButton
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
@ -272,15 +272,15 @@ begin
|
||||||
#3'Image was generated!'#13 +
|
#3'Image was generated!'#13 +
|
||||||
'File name: ' + fname + #13 +
|
'File name: ' + fname + #13 +
|
||||||
'Time spent: ' + FloatToStr(t) + ' s',
|
'Time spent: ' + FloatToStr(t) + ' s',
|
||||||
nil,
|
nil,
|
||||||
mfInformation or mfOkButton
|
mfInformation or mfOkButton
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMSApp.HandleEvent(var Event: TEvent);
|
procedure TMSApp.HandleEvent(var Event: TEvent);
|
||||||
begin
|
begin
|
||||||
inherited HandleEvent(Event);
|
inherited HandleEvent(Event);
|
||||||
|
|
||||||
if Event.What = evCommand then begin
|
if Event.What = evCommand then begin
|
||||||
case Event.Command of
|
case Event.Command of
|
||||||
cmMbNew: begin
|
cmMbNew: begin
|
||||||
|
@ -315,10 +315,11 @@ begin
|
||||||
r.a.y := r.b.y - 1;
|
r.a.y := r.b.y - 1;
|
||||||
New(StatusLine, Init(r,
|
New(StatusLine, Init(r,
|
||||||
NewStatusDef(0, $EFFF,
|
NewStatusDef(0, $EFFF,
|
||||||
NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit,
|
NewStatusKey('~F2~ Exit', kbF2, cmQuit,
|
||||||
NewStatusKey('~F3~ New', kbF3, cmMbNew,
|
NewStatusKey('~F3~ New Mb', kbF3, cmMbNew,
|
||||||
nil
|
NewStatusKey('~F4~ New Fn', kbF4, cmFnNew,
|
||||||
)), nil)
|
nil
|
||||||
|
))), nil)
|
||||||
));
|
));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user