GradientForm and SizeTool integrated into AdjustForm, MainForm replaced with my version to support all these changes

This commit is contained in:
zueuk 2005-09-11 07:09:54 +00:00
parent 60ad8965d1
commit 8e90d82350
7 changed files with 2805 additions and 644 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ object GradientBrowser: TGradientBrowser
Left = 0 Left = 0
Top = 4 Top = 4
Width = 372 Width = 372
Height = 106 Height = 105
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 0 TabOrder = 0
@ -62,7 +62,7 @@ object GradientBrowser: TGradientBrowser
Left = 0 Left = 0
Top = 0 Top = 0
Width = 372 Width = 372
Height = 106 Height = 105
Align = alClient Align = alClient
Columns = < Columns = <
item item
@ -98,7 +98,7 @@ object GradientBrowser: TGradientBrowser
end end
object pnlControls: TPanel object pnlControls: TPanel
Left = 0 Left = 0
Top = 110 Top = 109
Width = 372 Width = 372
Height = 51 Height = 51
Align = alBottom Align = alBottom

View File

@ -90,7 +90,7 @@ function CreatePalette(strng: string): TColorMap;
implementation implementation
uses Main, Options, Editor, Gradient, Registry, Adjust, Mutate; uses Main, Options, Editor, {Gradient,} Registry, Adjust, Mutate;
{$R *.DFM} {$R *.DFM}
@ -470,7 +470,8 @@ begin
MainForm.StopThread; MainForm.StopThread;
MainForm.UpdateUndo; MainForm.UpdateUndo;
MainCp.cmap := Palette; MainCp.cmap := Palette;
gradientForm.UpdateGradient(Palette); //gradientForm.UpdateGradient(Palette);
AdjustForm.UpdateGradient(Palette);
if EditForm.Visible then EditForm.UpdateDisplay; if EditForm.Visible then EditForm.UpdateDisplay;
// if AdjustForm.Visible then AdjustForm.UpdateDisplay; // if AdjustForm.Visible then AdjustForm.UpdateDisplay;
if MutateForm.Visible then MutateForm.UpdateDisplay; if MutateForm.Visible then MutateForm.UpdateDisplay;

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
} }
//{$D-,L-,O+,Q-,R-,Y-,S-} //{$D-,L-,O+,Q-,R-,Y-,S-}
unit Main; unit Main;
interface interface
@ -25,9 +26,10 @@ uses
Windows, Forms, Dialogs, Menus, Controls, ComCtrls, Windows, Forms, Dialogs, Menus, Controls, ComCtrls,
ToolWin, StdCtrls, Classes, Messages, ExtCtrls, ImgList, controlpoint, ToolWin, StdCtrls, Classes, Messages, ExtCtrls, ImgList, controlpoint,
Jpeg, SyncObjs, SysUtils, ClipBrd, Graphics, Math, Global, MyTypes, Jpeg, SyncObjs, SysUtils, ClipBrd, Graphics, Math, Global, MyTypes,
Registry, RenderThread, Cmap, ExtDlgs, AppEvnts, ShellAPI, IdComponent, Registry, RenderThread, Cmap, ExtDlgs, AppEvnts, ShellAPI,
IdTCPConnection, IdTCPClient, IdHTTP, IdBaseComponent, IdIntercept, // IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
IdLogBase, IdLogFile, LibXmlParser, LibXmlComps, Xform; // IdBaseComponent, IdIntercept, IdLogBase, IdLogFile,
LibXmlParser, LibXmlComps, Xform;
const const
PixelCountMax = 32768; PixelCountMax = 32768;
@ -90,7 +92,6 @@ type
ToolBar: TToolBar; ToolBar: TToolBar;
btnOpen: TToolButton; btnOpen: TToolButton;
btnSave: TToolButton; btnSave: TToolButton;
btnCopyUPR: TToolButton;
btnEditor: TToolButton; btnEditor: TToolButton;
btnGradient: TToolButton; btnGradient: TToolButton;
ToolButton9: TToolButton; ToolButton9: TToolButton;
@ -112,7 +113,6 @@ type
N11: TMenuItem; N11: TMenuItem;
mnuAbout: TMenuItem; mnuAbout: TMenuItem;
mnuFullScreen: TMenuItem; mnuFullScreen: TMenuItem;
N12: TMenuItem;
mnuRender: TMenuItem; mnuRender: TMenuItem;
mnuMutate: TMenuItem; mnuMutate: TMenuItem;
btnMutate: TToolButton; btnMutate: TToolButton;
@ -146,7 +146,6 @@ type
mnuRun: TMenuItem; mnuRun: TMenuItem;
mnuEditScript: TMenuItem; mnuEditScript: TMenuItem;
N15: TMenuItem; N15: TMenuItem;
ToolButton2: TToolButton;
btnRun: TToolButton; btnRun: TToolButton;
mnuStop: TMenuItem; mnuStop: TMenuItem;
btnStop: TToolButton; btnStop: TToolButton;
@ -162,12 +161,8 @@ type
mnuPaste: TMenuItem; mnuPaste: TMenuItem;
mnuCopy: TMenuItem; mnuCopy: TMenuItem;
N20: TMenuItem; N20: TMenuItem;
btnCopy: TToolButton;
btnPaste: TToolButton;
mnuExportFLame: TMenuItem; mnuExportFLame: TMenuItem;
mnuPostSheep: TMenuItem; mnuPostSheep: TMenuItem;
LogFile: TIdLogFile;
HTTP: TIdHTTP;
ListXmlScanner: TEasyXmlScanner; ListXmlScanner: TEasyXmlScanner;
N21: TMenuItem; N21: TMenuItem;
XmlScanner: TXmlScanner; XmlScanner: TXmlScanner;
@ -179,6 +174,12 @@ type
mnuimage: TMenuItem; mnuimage: TMenuItem;
tbzoomoutwindow: TToolButton; tbzoomoutwindow: TToolButton;
mnuSaveAllAs: TMenuItem; mnuSaveAllAs: TMenuItem;
ToolButton5: TToolButton;
btnSize: TToolButton;
btnFullScreen: TToolButton;
ToolButton6: TToolButton;
tbQualityBox: TComboBox;
View1: TMenuItem;
procedure tbzoomoutwindowClick(Sender: TObject); procedure tbzoomoutwindowClick(Sender: TObject);
procedure mnuimageClick(Sender: TObject); procedure mnuimageClick(Sender: TObject);
procedure mnuExitClick(Sender: TObject); procedure mnuExitClick(Sender: TObject);
@ -254,11 +255,13 @@ type
procedure mnuCopyClick(Sender: TObject); procedure mnuCopyClick(Sender: TObject);
procedure mnuExportFLameClick(Sender: TObject); procedure mnuExportFLameClick(Sender: TObject);
procedure mnuPostSheepClick(Sender: TObject); procedure mnuPostSheepClick(Sender: TObject);
{
procedure HTTPRedirect(Sender: TObject; var dest: string; procedure HTTPRedirect(Sender: TObject; var dest: string;
var NumRedirect: Integer; var Handled: Boolean; var NumRedirect: Integer; var Handled: Boolean;
var VMethod: TIdHTTPMethod); var VMethod: TIdHTTPMethod);
procedure HTTPStatus(ASender: TObject; const AStatus: TIdStatus; procedure HTTPStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string); const AStatusText: string);
}
procedure ListXmlScannerStartTag(Sender: TObject; TagName: string; procedure ListXmlScannerStartTag(Sender: TObject; TagName: string;
Attributes: TAttrList); Attributes: TAttrList);
procedure XMLScannerStartTag(Sender: TObject; TagName: string; procedure XMLScannerStartTag(Sender: TObject; TagName: string;
@ -276,12 +279,16 @@ type
procedure tbDragClick(Sender: TObject); procedure tbDragClick(Sender: TObject);
procedure tbRotateClick(Sender: TObject); procedure tbRotateClick(Sender: TObject);
procedure mnuSaveAllAsClick(Sender: TObject); procedure mnuSaveAllAsClick(Sender: TObject);
procedure tbQualityBoxKeyPress(Sender: TObject; var Key: Char);
procedure tbQualityBoxSet(Sender: TObject);
procedure ImageDblClick(Sender: TObject);
private private
Renderer: TRenderThread; Renderer: TRenderThread;
FMouseMoveState: TMouseMoveState; FMouseMoveState: TMouseMoveState;
FSelectRect: TRect; FSelectRect: TRect;
FRotateAngle: double; FRotateAngle: double;
FClickAngle: double; // --Z--
FViewBMP: Graphics.TBitmap; FViewBMP: Graphics.TBitmap;
procedure DrawZoomWindow(ARect: TRect); procedure DrawZoomWindow(ARect: TRect);
@ -362,10 +369,10 @@ var
implementation implementation
uses Editor, Options, Regstry, Gradient, Render, uses Editor, Options, Regstry, {Gradient,} Render,
FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData, FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData,
HtmlHlp, ScriptForm, FormFavorites, Size, FormExport, msMultiPartFormData, HtmlHlp, ScriptForm, FormFavorites, {Size,} FormExport, msMultiPartFormData,
ImageColoring, RndFlame; {Sheep,} ImageColoring, RndFlame;
{$R *.DFM} {$R *.DFM}
@ -565,7 +572,7 @@ var
URL, HelpTopic: string; URL, HelpTopic: string;
begin begin
if EditForm.Active then HelpTopic := 'Transform editor.htm' if EditForm.Active then HelpTopic := 'Transform editor.htm'
else if GradientForm.Active then HelpTopic := 'Gradient window.htm' // else if GradientForm.Active then HelpTopic := 'Gradient window.htm'
else if AdjustForm.Active then HelpTopic := 'Adjust window.htm' else if AdjustForm.Active then HelpTopic := 'Adjust window.htm'
else if MutateForm.Active then HelpTopic := 'Mutation window.htm' else if MutateForm.Active then HelpTopic := 'Mutation window.htm'
else if RenderForm.Active then HelpTopic := 'Render window.htm'; else if RenderForm.Active then HelpTopic := 'Render window.htm';
@ -906,6 +913,10 @@ begin
btnRedo.Enabled := false; btnRedo.Enabled := false;
EditForm.mnuUndo.Enabled := True; EditForm.mnuUndo.Enabled := True;
EditForm.mnuRedo.Enabled := false; EditForm.mnuRedo.Enabled := false;
EditForm.tbUndo.enabled := true;
EditForm.tbRedo.enabled := false;
AdjustForm.btnUndo.enabled := true;
AdjustForm.btnRedo.enabled := false;
end; end;
function GradientEntries(gFilename: string): string; function GradientEntries(gFilename: string): string;
@ -972,7 +983,7 @@ function CleanEntry(ident: string): string;
var var
i: integer; i: integer;
begin begin
for i := 0 to Length(ident) do for i := 1 to Length(ident) do
begin begin
if ident[i] = #32 then if ident[i] = #32 then
ident[i] := '_' ident[i] := '_'
@ -988,7 +999,7 @@ function CleanXMLName(ident: string): string;
var var
i: integer; i: integer;
begin begin
for i := 0 to Length(ident) do for i := 1 to Length(ident) do
begin begin
if ident[i] = '*' then if ident[i] = '*' then
ident[i] := '_' ident[i] := '_'
@ -1004,7 +1015,7 @@ function CleanUPRTitle(ident: string): string;
var var
i: integer; i: integer;
begin begin
for i := 0 to Length(ident) do for i := 1 to Length(ident) do
begin begin
if ident[i] = '}' then if ident[i] = '}' then
ident[i] := '_' ident[i] := '_'
@ -1778,8 +1789,14 @@ begin
if not Assigned(Renderer) then if not Assigned(Renderer) then
begin begin
if (MainCp.width <> Image.Width) or (MainCp.height <> Image.height) then if (MainCp.width <> Image.Width) or (MainCp.height <> Image.height) then
begin
AdjustScale(MainCp, Image.width, Image.height); AdjustScale(MainCp, Image.width, Image.height);
AdjustForm.UpdateDisplay; if EditForm.Visible then EditForm.UpdateDisplay(true); // preview only
end;
if AdjustForm.Visible then AdjustForm.UpdateDisplay;
//z GradientForm.DrawPreview;
// following needed ? // following needed ?
// cp.Zoom := Zoom; // cp.Zoom := Zoom;
// cp.center[0] := center[0]; // cp.center[0] := center[0];
@ -2077,7 +2094,7 @@ begin
mnuListRename.Enabled := True; mnuListRename.Enabled := True;
mnuItemDelete.Enabled := True; mnuItemDelete.Enabled := True;
OpenFile := OpenDialog.FileName; OpenFile := OpenDialog.FileName;
MainForm.Caption := 'Apophysis' + ' - ' + OpenFile; MainForm.Caption := 'Apophysis 2.02zx' + ' - ' + OpenFile; // --Z--
OpenFileType := ftXML; OpenFileType := ftXML;
if UpperCase(ExtractFileExt(OpenDialog.FileName)) = '.IFS' then if UpperCase(ExtractFileExt(OpenDialog.FileName)) = '.IFS' then
begin begin
@ -2157,6 +2174,11 @@ end;
procedure TMainForm.mnuOptionsClick(Sender: TObject); procedure TMainForm.mnuOptionsClick(Sender: TObject);
begin begin
OptionsForm.ShowModal; OptionsForm.ShowModal;
// --Z--
StopThread;
RedrawTimer.Enabled := True;
tbQualityBox.Text := FloatToStr(defSampleDensity);
UpdateWindows;
end; end;
procedure TMainForm.mnuRefreshClick(Sender: TObject); procedure TMainForm.mnuRefreshClick(Sender: TObject);
@ -2192,7 +2214,7 @@ begin
RandomBatch; RandomBatch;
OpenFile := AppPath + 'apophysis.rand'; OpenFile := AppPath + 'apophysis.rand';
OpenFileType := ftXML; OpenFileType := ftXML;
MainForm.Caption := 'Apophysis' + ' - Random Batch'; MainForm.Caption := 'Apophysis 2.02zx' + ' - Random Batch';
ListXML(OpenFile, 1); ListXML(OpenFile, 1);
ListView.SetFocus; ListView.SetFocus;
if batchsize = 1 then DrawFlame; if batchsize = 1 then DrawFlame;
@ -2307,7 +2329,9 @@ begin
MainCp.name := RandomPrefix + RandomDate + '-' + MainCp.name := RandomPrefix + RandomDate + '-' +
IntToStr(RandomIndex); IntToStr(RandomIndex);
Transforms := TrianglesFromCP(MainCp, MainTriangles); Transforms := TrianglesFromCP(MainCp, MainTriangles);
if GradientForm.visible then GradientForm.UpdateGradient(Maincp.cmap); // if GradientForm.visible then GradientForm.UpdateGradient(Maincp.cmap);
if AdjustForm.visible then AdjustForm.UpdateGradient(Maincp.cmap);
StatusBar.Panels[2].text := maincp.name; StatusBar.Panels[2].text := maincp.name;
ResetLocation; ResetLocation;
RedrawTimer.Enabled := true; RedrawTimer.Enabled := true;
@ -2516,7 +2540,7 @@ procedure TMainForm.FormCreate(Sender: TObject);
var var
dte: string; dte: string;
begin begin
FMouseMoveState := msZoomWindow; FMouseMoveState := msDrag; // --Z-- was: msZoomWindow;
LimitVibrancy := True; LimitVibrancy := True;
Favorites := TStringList.Create; Favorites := TStringList.Create;
GetScripts; GetScripts;
@ -2539,6 +2563,8 @@ begin
if VariationOptions = 0 then VariationOptions := 16383; // it shouldn't hapen but just in case; if VariationOptions = 0 then VariationOptions := 16383; // it shouldn't hapen but just in case;
UnpackVariations(VariationOptions); UnpackVariations(VariationOptions);
FillVariantMenu; FillVariantMenu;
tbQualityBox.Text := FloatToStr(defSampleDensity);
end; end;
procedure TMainForm.FormShow(Sender: TObject); procedure TMainForm.FormShow(Sender: TObject);
@ -2546,7 +2572,7 @@ var
Registry: TRegistry; Registry: TRegistry;
i: integer; i: integer;
begin begin
{ Read posution from registry } { Read position from registry }
Registry := TRegistry.Create; Registry := TRegistry.Create;
try try
Registry.RootKey := HKEY_CURRENT_USER; Registry.RootKey := HKEY_CURRENT_USER;
@ -2599,7 +2625,7 @@ begin
MainCp.Width := image.width; MainCp.Width := image.width;
MainCp.Height := Image.Height; MainCp.Height := Image.Height;
RandomBatch; RandomBatch;
MainForm.Caption := 'Apophysis' + ' - Random Batch'; MainForm.Caption := 'Apophysis 2.02zx' + ' - Random Batch';
OpenFile := AppPath + 'apophysis.rand'; OpenFile := AppPath + 'apophysis.rand';
ListXML(OpenFile, 1); ListXML(OpenFile, 1);
OpenFileType := ftXML; OpenFileType := ftXML;
@ -2619,15 +2645,23 @@ begin
OpenFileType := ftXML; OpenFileType := ftXML;
MainForm.ListView.Selected := MainForm.ListView.Items[0]; MainForm.ListView.Selected := MainForm.ListView.Items[0];
end; end;
MainForm.Caption := 'Apophysis' + ' - ' + defFlameFile; MainForm.Caption := 'Apophysis 2.02zx' + ' - ' + defFlameFile;
end; end;
ListView.SetFocus; ListView.SetFocus;
CanDrawOnResize := True; CanDrawOnResize := True;
Statusbar.Panels[2].Text := maincp.name; Statusbar.Panels[2].Text := maincp.name;
{
gradientForm.cmbPalette.Items.clear; gradientForm.cmbPalette.Items.clear;
for i := 0 to NRCMAPS -1 do for i := 0 to NRCMAPS -1 do
gradientForm.cmbPalette.Items.Add(cMapnames[i]); gradientForm.cmbPalette.Items.Add(cMapnames[i]);
GradientForm.cmbPalette.ItemIndex := 0; GradientForm.cmbPalette.ItemIndex := 0;
}
AdjustForm.cmbPalette.Items.clear;
for i := 0 to NRCMAPS -1 do
AdjustForm.cmbPalette.Items.Add(cMapnames[i]);
AdjustForm.cmbPalette.ItemIndex := 0;
// AdjustForm.cmbPalette.Items.clear;
ExportDialog.cmbDepth.ItemIndex := 2; ExportDialog.cmbDepth.ItemIndex := 2;
end; end;
@ -2642,7 +2676,7 @@ begin
if AdjustForm.visible then AdjustForm.close; if AdjustForm.visible then AdjustForm.close;
if GradientBrowser.visible then GradientBrowser.close; if GradientBrowser.visible then GradientBrowser.close;
if MutateForm.visible then MutateForm.Close; if MutateForm.visible then MutateForm.Close;
if GradientForm.visible then GradientForm.Close; // if GradientForm.visible then GradientForm.Close;
if ScriptEditor.visible then ScriptEditor.Close; if ScriptEditor.visible then ScriptEditor.Close;
{ Stop the render thread } { Stop the render thread }
if RenderForm.Visible then RenderForm.Close; if RenderForm.Visible then RenderForm.Close;
@ -2755,6 +2789,10 @@ begin
mnuPopRedo.enabled := False; mnuPopRedo.enabled := False;
EditForm.mnuUndo.Enabled := False; EditForm.mnuUndo.Enabled := False;
EditForm.mnuRedo.enabled := False; EditForm.mnuRedo.enabled := False;
EditForm.tbUndo.enabled := false;
EditForm.tbRedo.enabled := false;
AdjustForm.btnUndo.enabled := false;
AdjustForm.btnRedo.enabled := false;
btnUndo.Enabled := false; btnUndo.Enabled := false;
btnRedo.enabled := false; btnRedo.enabled := false;
@ -2766,6 +2804,9 @@ begin
Statusbar.Panels[2].Text := Maincp.name; Statusbar.Panels[2].Text := Maincp.name;
RedrawTimer.Enabled := True; RedrawTimer.Enabled := True;
Application.ProcessMessages; Application.ProcessMessages;
EditForm.SelectedTriangle := 1; // --Z--
UpdateWindows; UpdateWindows;
finally finally
FileStrings.free; FileStrings.free;
@ -2888,6 +2929,10 @@ begin
mnuPopRedo.enabled := False; mnuPopRedo.enabled := False;
EditForm.mnuUndo.Enabled := False; EditForm.mnuUndo.Enabled := False;
EditForm.mnuRedo.enabled := False; EditForm.mnuRedo.enabled := False;
EditForm.tbUndo.enabled := false;
EditForm.tbRedo.enabled := false;
AdjustForm.btnUndo.enabled := false;
AdjustForm.btnRedo.enabled := false;
btnUndo.Enabled := false; btnUndo.Enabled := false;
btnRedo.enabled := false; btnRedo.enabled := false;
Transforms := TrianglesFromCP(maincp, MainTriangles); Transforms := TrianglesFromCP(maincp, MainTriangles);
@ -2917,8 +2962,11 @@ end;
procedure TMainForm.UpdateWindows; procedure TMainForm.UpdateWindows;
begin begin
if GradientForm.visible then GradientForm.UpdateGradient(maincp.cmap); if AdjustForm.visible then AdjustForm.UpdateGradient(maincp.cmap);
// if GradientForm.visible then GradientForm.UpdateGradient(maincp.cmap);
if EditForm.visible then EditForm.UpdateDisplay; if EditForm.visible then EditForm.UpdateDisplay;
// if AdjustForm.visible then AdjustForm.UpdateDisplay; // if AdjustForm.visible then AdjustForm.UpdateDisplay;
if MutateForm.visible then MutateForm.UpdateDisplay; if MutateForm.visible then MutateForm.UpdateDisplay;
end; end;
@ -2988,7 +3036,8 @@ begin
// Trim undo index from title // Trim undo index from title
maincp.name := Copy(Fstrings[0], 6, length(Fstrings[0]) - 7); maincp.name := Copy(Fstrings[0], 6, length(Fstrings[0]) - 7);
if SavedPal then maincp.cmap := palette; if SavedPal then maincp.cmap := palette;
if GradientForm.visible then GradientForm.UpdateGradient(maincp.cmap); // if GradientForm.visible then GradientForm.UpdateGradient(maincp.cmap);
if AdjustForm.visible then AdjustForm.UpdateGradient(maincp.cmap);
RedrawTimer.Enabled := True; RedrawTimer.Enabled := True;
UpdateWindows; UpdateWindows;
finally finally
@ -3055,8 +3104,11 @@ end;
procedure TMainForm.mnuGradClick(Sender: TObject); procedure TMainForm.mnuGradClick(Sender: TObject);
begin begin
gradientForm.UpdateGradient(maincp.cmap); //gradientForm.UpdateGradient(maincp.cmap);
GradientForm.Show; //GradientForm.Show;
AdjustForm.UpdateDisplay;
AdjustForm.PageControl.TabIndex:=2;
AdjustForm.Show;
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -3230,7 +3282,9 @@ begin
StopThread; StopThread;
UpdateUndo; UpdateUndo;
maincp.cmap := Pal; maincp.cmap := Pal;
gradientForm.UpdateGradient(Pal); // gradientForm.UpdateGradient(Pal);
{if AdjustForm.visible then} AdjustForm.UpdateGradient(maincp.cmap);
if EditForm.Visible then EditForm.UpdateDisplay; if EditForm.Visible then EditForm.UpdateDisplay;
// if AdjustForm.Visible then AdjustForm.UpdateDisplay; // if AdjustForm.Visible then AdjustForm.UpdateDisplay;
if MutateForm.Visible then MutateForm.UpdateDisplay; if MutateForm.Visible then MutateForm.UpdateDisplay;
@ -3276,11 +3330,15 @@ begin
mnuPopRedo.Enabled := True; mnuPopRedo.Enabled := True;
btnRedo.Enabled := True; btnRedo.Enabled := True;
EditForm.mnuRedo.Enabled := True; EditForm.mnuRedo.Enabled := True;
EditForm.tbRedo.enabled := true;
AdjustForm.btnRedo.enabled := true;
if UndoIndex = 0 then begin if UndoIndex = 0 then begin
mnuUndo.Enabled := false; mnuUndo.Enabled := false;
mnuPopUndo.Enabled := false; mnuPopUndo.Enabled := false;
btnUndo.Enabled := false; btnUndo.Enabled := false;
EditForm.mnuUndo.Enabled := false; EditForm.mnuUndo.Enabled := false;
EditForm.tbUndo.enabled := false;
AdjustForm.btnUndo.enabled := false;
end; end;
end; end;
@ -3294,16 +3352,23 @@ procedure TMainForm.Redo;
begin begin
StopThread; StopThread;
Inc(UndoIndex); Inc(UndoIndex);
assert(UndoIndex < UndoMax, 'Undo list index out of range!');
LoadUndoFlame(UndoIndex, AppPath + 'apophysis.undo'); LoadUndoFlame(UndoIndex, AppPath + 'apophysis.undo');
mnuUndo.Enabled := True; mnuUndo.Enabled := True;
mnuPopUndo.Enabled := True; mnuPopUndo.Enabled := True;
btnUndo.Enabled := True; btnUndo.Enabled := True;
EditForm.mnuUndo.Enabled := True; EditForm.mnuUndo.Enabled := True;
EditForm.tbUndo.enabled := true;
AdjustForm.btnUndo.enabled := true;
if UndoIndex = UndoMax then begin if UndoIndex = UndoMax then begin
mnuRedo.Enabled := false; mnuRedo.Enabled := false;
mnuPopRedo.Enabled := True; mnuPopRedo.Enabled := false;
btnRedo.Enabled := false; btnRedo.Enabled := false;
EditForm.mnuRedo.Enabled := false; EditForm.mnuRedo.Enabled := false;
EditForm.tbRedo.enabled := false;
AdjustForm.btnRedo.enabled := false;
end; end;
end; end;
@ -3384,6 +3449,7 @@ end;
procedure TMainForm.mnuAdjustClick(Sender: TObject); procedure TMainForm.mnuAdjustClick(Sender: TObject);
begin begin
AdjustForm.UpdateDisplay; AdjustForm.UpdateDisplay;
AdjustForm.PageControl.TabIndex := 0;
AdjustForm.Show; AdjustForm.Show;
end; end;
@ -3597,30 +3663,37 @@ end;
procedure TMainForm.mnuImageSizeClick(Sender: TObject); procedure TMainForm.mnuImageSizeClick(Sender: TObject);
begin begin
SizeTool.Show; // SizeTool.Show;
AdjustForm.UpdateDisplay;
AdjustForm.PageControl.TabIndex:=3;
AdjustForm.Show;
end; end;
procedure TMainForm.ApplicationEventsActivate(Sender: TObject); procedure TMainForm.ApplicationEventsActivate(Sender: TObject);
begin begin
if GradientInClipboard then if GradientInClipboard then
begin begin
GradientForm.mnuPaste.enabled := true; // GradientForm.mnuPaste.enabled := true;
GradientForm.btnPaste.enabled := true; // GradientForm.btnPaste.enabled := true;
AdjustForm.mnuPaste.enabled := true;
AdjustForm.btnPaste.enabled := true;
end end
else else
begin begin
GradientForm.mnuPaste.enabled := false; // GradientForm.mnuPaste.enabled := false;
GradientForm.btnPaste.enabled := false; // GradientForm.btnPaste.enabled := false;
AdjustForm.mnuPaste.enabled := false;
AdjustForm.btnPaste.enabled := false;
end; end;
if FlameInClipboard then if FlameInClipboard then
begin begin
mnuPaste.enabled := true; mnuPaste.enabled := true;
btnPaste.enabled := true; //z btnPaste.enabled := true;
end end
else else
begin begin
mnuPaste.enabled := false; mnuPaste.enabled := false;
btnPaste.enabled := false; //z btnPaste.enabled := false;
end; end;
end; end;
@ -3653,7 +3726,7 @@ begin
end; end;
end; end;
if nxform < 12 then if nxform < NXFORMS then
for i := nxform to NXFORMS - 1 do for i := nxform to NXFORMS - 1 do
cp1.xform[i].density := 0; cp1.xform[i].density := 0;
NormalizeWeights(cp1); NormalizeWeights(cp1);
@ -3686,9 +3759,12 @@ begin
txt := Trim(FlameToXML(Maincp, false, true)); txt := Trim(FlameToXML(Maincp, false, true));
Clipboard.SetTextBuf(PChar(txt)); Clipboard.SetTextBuf(PChar(txt));
mnuPaste.enabled := true; mnuPaste.enabled := true;
btnPaste.enabled := true; //z btnPaste.enabled := true;
GradientForm.mnuPaste.enabled := False;
GradientForm.btnPaste.enabled := False; // GradientForm.mnuPaste.enabled := False;
// GradientForm.btnPaste.enabled := False;
AdjustForm.mnuPaste.enabled := False;
AdjustForm.btnPaste.enabled := False;
end; end;
procedure WinShellExecute(const Operation, AssociatedFile: string); procedure WinShellExecute(const Operation, AssociatedFile: string);
@ -3822,11 +3898,13 @@ begin
end; end;
procedure TMainForm.mnuPostSheepClick(Sender: TObject); procedure TMainForm.mnuPostSheepClick(Sender: TObject);
//var {
// URL: string; var
// StringList: TStringList; URL: string;
// ResponseStream: TMemoryStream; StringList: TStringList;
// MultiPartFormDataStream: TmsMultiPartFormDataStream; ResponseStream: TMemoryStream;
MultiPartFormDataStream: TmsMultiPartFormDataStream;
}
begin begin
// if MainCp.HasNewVariants then begin // if MainCp.HasNewVariants then begin
// showMessage('The posting of sheep with new variants (exponential, power, cosine and sawtooth) is disabled in this version.'); // showMessage('The posting of sheep with new variants (exponential, power, cosine and sawtooth) is disabled in this version.');
@ -3837,7 +3915,7 @@ begin
// showMessage('The posting of sheep with are rotated is disabled in this version.'); // showMessage('The posting of sheep with are rotated is disabled in this version.');
// Exit; // Exit;
// end; // end;
(* {
if SheepDialog.ShowModal = mrOK then if SheepDialog.ShowModal = mrOK then
begin begin
DeleteFile('apophysis.log'); DeleteFile('apophysis.log');
@ -3856,7 +3934,7 @@ begin
MultiPartFormDataStream.AddFormField('nick', SheepDialog.txtNick.text); MultiPartFormDataStream.AddFormField('nick', SheepDialog.txtNick.text);
MultiPartFormDataStream.AddFormField('url', SheepDialog.txtURL.text); MultiPartFormDataStream.AddFormField('url', SheepDialog.txtURL.text);
MultiPartFormDataStream.AddFormField('pw', SheepPW); //SheepPw MultiPartFormDataStream.AddFormField('pw', SheepPW); //SheepPw
{ You must make sure you call this method *before* sending the stream } // You must make sure you call this method *before* sending the stream
MultiPartFormDataStream.PrepareStreamForDispatch; MultiPartFormDataStream.PrepareStreamForDispatch;
MultiPartFormDataStream.Position := 0; MultiPartFormDataStream.Position := 0;
URL := URLEncode(SheepServer + 'cgi/apophysis.cgi'); URL := URLEncode(SheepServer + 'cgi/apophysis.cgi');
@ -3877,9 +3955,10 @@ begin
logFile.Active := False; logFile.Active := False;
end; end;
end; end;
*) }
end; end;
{
procedure TMainForm.HTTPRedirect(Sender: TObject; var dest: string; procedure TMainForm.HTTPRedirect(Sender: TObject; var dest: string;
var NumRedirect: Integer; var Handled: Boolean; var NumRedirect: Integer; var Handled: Boolean;
var VMethod: TIdHTTPMethod); var VMethod: TIdHTTPMethod);
@ -3897,6 +3976,7 @@ procedure TMainForm.HTTPStatus(ASender: TObject; const AStatus: TIdStatus;
begin begin
StatusBar.SimpleText := AStatusTExt; StatusBar.SimpleText := AStatusTExt;
end; end;
}
procedure TMainForm.ListXmlScannerStartTag(Sender: TObject; procedure TMainForm.ListXmlScannerStartTag(Sender: TObject;
TagName: string; Attributes: TAttrList); TagName: string; Attributes: TAttrList);
@ -4147,6 +4227,8 @@ begin
end; end;
msRotate: msRotate:
begin begin
FClickAngle:=arctan2(y-Image.Height/2, Image.Width/2-x);
FRotateAngle := 0; FRotateAngle := 0;
FSelectRect.Left := x; FSelectRect.Left := x;
DrawRotateLines(FRotateAngle); DrawRotateLines(FRotateAngle);
@ -4189,13 +4271,21 @@ begin
begin begin
DrawRotatelines(FRotateAngle); DrawRotatelines(FRotateAngle);
FRotateAngle := FRotateAngle + 0.004 * (FSelectRect.Left - X); // FRotateAngle := FRotateAngle + 0.004 * (FSelectRect.Left - X);
FRotateAngle:=arctan2(y-Image.Height/2, Image.Width/2-x) - FClickAngle;
FSelectRect.Left := x; FSelectRect.Left := x;
// pdjpointgen.Rotate(FRotateAngle); // pdjpointgen.Rotate(FRotateAngle);
// FRotateAngle := 0; // FRotateAngle := 0;
DrawRotatelines(FRotateAngle); DrawRotatelines(FRotateAngle);
{
Image.Refresh;
if AdjustForm.Visible then begin
MainCp.FAngle:=-FRotateAngle;
AdjustForm.UpdateDisplay;
end;
}
end; end;
end; end;
end; end;
@ -4245,8 +4335,9 @@ begin
FSelectRect.BottomRight := Point(x, y); FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msDrag; FMouseMoveState := msDrag;
if (x = 0) and (y = 0) then if ((x = 0) and (y = 0)) or // double clicked
Exit; // double clicked ((FSelectRect.left = FSelectRect.right) and (FSelectRect.top = FSelectRect.bottom))
then Exit;
StopThread; StopThread;
UpdateUndo; UpdateUndo;
@ -4261,12 +4352,11 @@ begin
FMouseMoveState := msRotate; FMouseMoveState := msRotate;
if (FRotateAngle = 0) then if (FRotateAngle = 0) then Exit; // double clicked
Exit; // double clicked
StopThread; StopThread;
UpdateUndo; UpdateUndo;
MainCp.Rotate(FRotateAngle); MainCp.Rotate(-FRotateAngle); // "-" by Zueuk
RedrawTimer.Enabled := True; RedrawTimer.Enabled := True;
UpdateWindows; UpdateWindows;
@ -4289,14 +4379,14 @@ begin
Image.Canvas.Brush.Style := bsClear; Image.Canvas.Brush.Style := bsClear;
// Image.Canvas.Rectangle(FSelectRect); // Image.Canvas.Rectangle(FSelectRect);
points[0].x := -Image.Width div 4; points[0].x := (Image.Width div 2)-1;
points[0].y := -Image.Height div 4; points[0].y := (Image.Height div 2)-1;
points[1].x := -Image.Width div 4; points[1].x := (Image.Width div 2)-1;
points[1].y := Image.Height div 4; points[1].y := -Image.Height div 2;
points[2].x := Image.Width div 4; points[2].x := -Image.Width div 2;
points[2].y := Image.Height div 4; points[2].y := -Image.Height div 2;
points[3].x := Image.Width div 4; points[3].x := -Image.Width div 2;
points[3].y := -Image.Height div 4; points[3].y := (Image.Height div 2)-1;
for i := 0 to 3 do begin for i := 0 to 3 do begin
x := points[i].x; x := points[i].x;
@ -4378,6 +4468,7 @@ begin
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.VariantMenuClick(Sender: TObject); procedure TMainForm.VariantMenuClick(Sender: TObject);
begin begin
TMenuItem(Sender).Checked := True; TMenuItem(Sender).Checked := True;
@ -4389,4 +4480,98 @@ begin
UpdateWindows; UpdateWindows;
end; end;
//--Z--////////////////////////////////////////////////////////////////////////
procedure TMainForm.tbQualityBoxKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
tbQualityBoxSet(Sender);
key := #0;
end
else if key = #27 then tbQualityBox.Text := FloatToStr(defSampleDensity);
end;
procedure TMainForm.tbQualityBoxSet(Sender: TObject);
var
q: double;
begin
try
q := StrToFloat(tbQualityBox.Text);
except
exit;
end;
defSampleDensity := q;
StopThread;
RedrawTimer.Enabled := True;
UpdateWindows;
end;
procedure TMainForm.ImageDblClick(Sender: TObject);
begin
if FMouseMoveState = msRotateMove then
begin
// FRotateAngle := 0;
StopThread;
UpdateUndo;
MainCp.FAngle := 0;
RedrawTimer.Enabled := True;
UpdateWindows;
end
else mnuResetLocationClick(Sender);
{ msDragMove:
begin
FViewBMP.Free;
FViewBMP := nil;
FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msDrag;
if (x = 0) and (y = 0) then
Exit; // double clicked
StopThread;
UpdateUndo;
MainCp.MoveRect(FSelectRect);
RedrawTimer.Enabled := True;
UpdateWindows;
end;
msZoomWindowMove:
begin
DrawZoomWindow(FSelectRect);
FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msZoomWindow;
if (abs(FSelectRect.Left - FSelectRect.Right) < 10) or
(abs(FSelectRect.Top - FSelectRect.Bottom) < 10) then
Exit; // zoom to much or double clicked
StopThread;
UpdateUndo;
MainCp.ZoomtoRect(FSelectRect);
RedrawTimer.Enabled := True;
UpdateWindows;
end;
msZoomOutWindowMove:
begin
DrawZoomWindow(FSelectRect);
FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msZoomOutWindow;
if (abs(FSelectRect.Left - FSelectRect.Right) < 10) or
(abs(FSelectRect.Top - FSelectRect.Bottom) < 10) then
Exit; // zoom to much or double clicked
StopThread;
UpdateUndo;
MainCp.ZoomOuttoRect(FSelectRect);
RedrawTimer.Enabled := True;
UpdateWindows;
end;
end;
}
end;
end. end.

View File

@ -22,7 +22,7 @@ interface
uses uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ControlPoint, cmap, Buttons, ComCtrls, ToolWin, ExtCtrls, StdCtrls, ControlPoint, cmap, Buttons, ComCtrls, ToolWin,
Menus, atScript, atPascal, AdvMemo, Advmps, XForm; Menus, atScript, atPascal, AdvMemo, Advmps, XForm, GradientHlpr;
const NCPS = 10; const NCPS = 10;
type type
@ -324,7 +324,7 @@ implementation
} }
uses Main, Editor, Adjust, Global, Mutate, Registry, Preview, uses Main, Editor, Adjust, Global, Mutate, Registry, Preview,
ScriptRender, Gradient, ap_math, ap_classes, ap_sysutils, MyTypes, ScriptRender, {Gradient,} ap_math, ap_classes, ap_sysutils, MyTypes,
SavePreset, ap_windows, ap_FileCtrl, bmdll32; SavePreset, ap_windows, ap_FileCtrl, bmdll32;
{$R *.DFM} {$R *.DFM}
@ -1188,7 +1188,7 @@ end;
procedure TOperationLibrary.RandomGradientProc(AMachine: TatVirtualMachine); procedure TOperationLibrary.RandomGradientProc(AMachine: TatVirtualMachine);
begin begin
ScriptEditor.cp.cmap := GradientForm.RandomGradient; ScriptEditor.cp.cmap := GradientHelper.RandomGradient;
end; end;
procedure TOperationLibrary.CalculateScale(AMachine: TatVirtualMachine); procedure TOperationLibrary.CalculateScale(AMachine: TatVirtualMachine);
@ -1470,7 +1470,7 @@ begin
HSVToRGB(h, s, v, cp1.cmap[i][0], cp1.cmap[i][1], cp1.cmap[i][2]); HSVToRGB(h, s, v, cp1.cmap[i][0], cp1.cmap[i][1], cp1.cmap[i][2]);
end; end;
end; end;
if nxform < 12 then if nxform < NXFORMS then
for i := nxform to NXFORMS - 1 do for i := nxform to NXFORMS - 1 do
cp1.xform[i].density := 0; cp1.xform[i].density := 0;
NormalizeWeights(cp1); NormalizeWeights(cp1);
@ -2713,7 +2713,7 @@ begin
Scripter.AddConstant('V_FAN', 22); Scripter.AddConstant('V_FAN', 22);
Scripter.AddConstant('V_RANDOM', -1); Scripter.AddConstant('V_RANDOM', -1);
{ Variables } { Variables }
Scripter.AddVariable('SelectedTransform', SelectedTriangle); Scripter.AddVariable('SelectedTransform', EditForm.SelectedTriangle);
Scripter.AddVariable('Compatibility', Compatibility); Scripter.AddVariable('Compatibility', Compatibility);
Scripter.AddVariable('ActiveTransform', ActiveTransform); Scripter.AddVariable('ActiveTransform', ActiveTransform);
Scripter.AddVariable('UpdateFlame', UpdateIt); Scripter.AddVariable('UpdateFlame', UpdateIt);
@ -2863,7 +2863,7 @@ begin
ResetLocation := False; ResetLocation := False;
Console.Clear; Console.Clear;
LastError := ''; LastError := '';
ActiveTransform := SelectedTriangle; ActiveTransform := EditForm.SelectedTriangle;
NumTransforms := Transforms; NumTransforms := Transforms;
cp.copy(MainCp); cp.copy(MainCp);
cmap := MainCp.cmap; cmap := MainCp.cmap;
@ -2959,7 +2959,8 @@ begin
if EditForm.Visible then EditForm.UpdateDisplay; if EditForm.Visible then EditForm.UpdateDisplay;
// if AdjustForm.Visible then AdjustForm.UpdateDisplay; // if AdjustForm.Visible then AdjustForm.UpdateDisplay;
if MutateForm.Visible then MutateForm.UpdateDisplay; if MutateForm.Visible then MutateForm.UpdateDisplay;
if GradientForm.Visible then GradientForm.UpdateGradient(cmap) // if GradientForm.Visible then GradientForm.UpdateGradient(cmap)
if AdjustForm.Visible then AdjustForm.UpdateGradient(cmap)
end; end;
{ ******************************* functions ********************************** } { ******************************* functions ********************************** }