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