some interface bugs fixed,

added option to choose between zoom & scale when zooming in MainForm
This commit is contained in:
zueuk 2006-09-18 15:52:16 +00:00
parent e72eee7dd9
commit eac94ba8a1
10 changed files with 154 additions and 44 deletions

View File

@ -1702,7 +1702,10 @@ begin
center[0] := center[0] + cos(FAngle) * dx - sin(FAngle) * dy;
center[1] := center[1] + sin(FAngle) * dx + cos(FAngle) * dy;
zoom := Log2(scale * ( Width/(abs(r.Right - r.Left) + 1)));
if PreserveQuality then
zoom := Log2(scale * ( Width/(abs(r.Right - r.Left) + 1)))
else
pixels_per_unit := pixels_per_unit * Width / abs(r.Right - r.Left);
end;
///////////////////////////////////////////////////////////////////////////////
@ -1711,7 +1714,11 @@ var
ppu: double;
dx, dy: double;
begin
zoom := Log2(power(2, zoom) / ( Width/(abs(r.Right - r.Left) + 1)));
if PreserveQuality then
zoom := Log2(power(2, zoom) / ( Width/(abs(r.Right - r.Left) + 1)))
else
pixels_per_unit := pixels_per_unit / Width * abs(r.Right - r.Left);
ppu := pixels_per_unit * power(2, zoom);
dx := ((r.Left + r.Right)/2 - Width/2) / ppu;

View File

@ -1157,8 +1157,10 @@ object EditForm: TEditForm
Height = 21
Hint = 'Reset vector X'
Caption = 'X'
Enabled = False
ParentShowHint = False
ShowHint = True
Visible = False
OnClick = btnXpostClick
end
object btnYpost: TSpeedButton
@ -1168,8 +1170,10 @@ object EditForm: TEditForm
Height = 21
Hint = 'Reset vector Y'
Caption = 'Y'
Enabled = False
ParentShowHint = False
ShowHint = True
Visible = False
OnClick = btnYpostClick
end
object btnOpost: TSpeedButton
@ -1179,8 +1183,10 @@ object EditForm: TEditForm
Height = 21
Hint = 'Reset vector O'
Caption = 'O'
Enabled = False
ParentShowHint = False
ShowHint = True
Visible = False
OnClick = btnOpostClick
end
object btnResetPostXForm: TSpeedButton
@ -1190,8 +1196,10 @@ object EditForm: TEditForm
Height = 22
Hint = 'Reset post-transform vectors to defaults'
Caption = 'Reset post-transform'
Enabled = False
ParentShowHint = False
ShowHint = True
Visible = False
OnClick = btnResetPostXFormClick
end
object btnPostTriangle: TSpeedButton
@ -1201,6 +1209,7 @@ object EditForm: TEditForm
Height = 22
Hint = 'Swap Xform with PostXform'
Caption = '[ Xform <-> PostXform ]'
Enabled = False
Flat = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
@ -1210,6 +1219,7 @@ object EditForm: TEditForm
ParentFont = False
ParentShowHint = False
ShowHint = True
Visible = False
OnClick = btnPostTriangleClick
end
object pnlWeight: TPanel
@ -1322,8 +1332,10 @@ object EditForm: TEditForm
Top = 188
Width = 57
Height = 21
Enabled = False
TabOrder = 8
Text = '0'
Visible = False
OnExit = PostCoefValidate
OnKeyPress = PostCoefKeypress
end
@ -1332,8 +1344,10 @@ object EditForm: TEditForm
Top = 188
Width = 57
Height = 21
Enabled = False
TabOrder = 9
Text = '0'
Visible = False
OnExit = PostCoefValidate
OnKeyPress = PostCoefKeypress
end
@ -1342,8 +1356,10 @@ object EditForm: TEditForm
Top = 212
Width = 57
Height = 21
Enabled = False
TabOrder = 10
Text = '0'
Visible = False
OnExit = PostCoefValidate
OnKeyPress = PostCoefKeypress
end
@ -1352,8 +1368,10 @@ object EditForm: TEditForm
Top = 212
Width = 57
Height = 21
Enabled = False
TabOrder = 11
Text = '0'
Visible = False
OnExit = PostCoefValidate
OnKeyPress = PostCoefKeypress
end
@ -1362,8 +1380,10 @@ object EditForm: TEditForm
Top = 236
Width = 57
Height = 21
Enabled = False
TabOrder = 12
Text = '0'
Visible = False
OnExit = PostCoefValidate
OnKeyPress = PostCoefKeypress
end
@ -1372,8 +1392,10 @@ object EditForm: TEditForm
Top = 236
Width = 57
Height = 21
Enabled = False
TabOrder = 13
Text = '0'
Visible = False
OnExit = PostCoefValidate
OnKeyPress = PostCoefKeypress
end

View File

@ -364,6 +364,8 @@ type
procedure UpdateFlameX;
procedure UpdateFlame(DrawMain: boolean);
procedure UpdateWidgets;
procedure UpdateXformsList;
procedure DeleteTriangle(t: integer);
function GetPivot: TSPoint; overload;
@ -589,9 +591,17 @@ begin
DrawPreview;
end;
procedure TEditForm.UpdateDisplay(PreviewOnly: boolean = false);
procedure TEditForm.UpdateXformsList;
var
i: integer;
begin
cbTransforms.Clear;
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
if EnableFinalXform or cp.HasFinalXForm then cbTransforms.Items.Add('Final');
cbTransforms.ItemIndex := SelectedTriangle;
end;
procedure TEditForm.UpdateDisplay(PreviewOnly: boolean = false);
begin
// currently EditForm does not really know if we select another
// flame in the Main Window - which is not good...
@ -614,9 +624,7 @@ begin
cp.cmap := MainCp.cmap;
cmap := MainCp.cmap;
cbTransforms.Clear;
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
if cp.HasFinalXForm then cbTransforms.Items.Add('Final');
UpdateXformsList;
// just in case:
SetCaptureControl(nil);
@ -912,10 +920,7 @@ begin
Dec(Transforms);
assert(cp.xform[transforms].density = 0); // cp.xform[transforms].density := 0;
end;
cbTransforms.clear;
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
if EnableFinalXform or (cp.HasFinalXForm = true) then cbTransforms.Items.Add('Final');
cbTransforms.ItemIndex := SelectedTriangle;
UpdateXformsList;
UpdateFlame(True);
end;
@ -1004,7 +1009,7 @@ var
procedure DrawWidgets;
var
i, j, n: integer;
i: integer;
begin
with Bitmap.Canvas do
with MainTriangles[SelectedTriangle] do
@ -1910,8 +1915,7 @@ end;
procedure TEditForm.TriangleViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
var
a, d, fx, fy: double;
dx, dy, x1, y1: double;
d, fx, fy: double;
i, j: integer;
i0, i1: integer;
label
@ -2225,8 +2229,6 @@ begin
end;
procedure TEditForm.mnuAddClick(Sender: TObject);
var
i: integer;
begin
if Transforms < NXFORMS then
begin
@ -2240,16 +2242,12 @@ begin
cp.xform[Transforms].vars[0] := 1;
// for i := 1 to NRVAR - 1 do cp.xform[Transforms].vars[i] := 0;
Inc(Transforms);
cbTransforms.clear;
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
if EnableFinalXform or (cp.HasFinalXForm = true) then cbTransforms.Items.Add('Final');
UpdateXformsList;
UpdateFlame(True);
end;
end;
procedure TEditForm.mnuDupClick(Sender: TObject);
var
i: integer;
begin
if Transforms < NXFORMS then
begin
@ -2264,9 +2262,7 @@ begin
end
else cp.xform[Transforms].density := 0.5;
Inc(Transforms);
cbTransforms.clear;
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
if EnableFinalXform or (cp.HasFinalXForm = true) then cbTransforms.Items.Add('Final');
UpdateXformsList;
UpdateFlame(True);
end;
end;
@ -2652,6 +2648,7 @@ var
ax,ay,bx,by: integer;
TrgColor: TColor;
begin
assert(Index >= 0);
TrgColor := GetTriangleColor(Index);
with cbTransforms.Canvas do
begin
@ -2821,8 +2818,6 @@ begin
end;
procedure TEditForm.txtXFormColorKeyPress(Sender: TObject; var Key: Char);
var
v: double;
begin
if key = #13 then
begin
@ -3100,7 +3095,7 @@ begin
assert(n >= 0);
assert(n < TValueListEditor(Sender).rowCount);
changed := false;
//changed := false;
if Sender = VEVars then
begin
@ -3601,7 +3596,6 @@ procedure TEditForm.ValidateVariable;
var
i: integer;
NewVal, OldVal: double;
str, oldstr: string;
begin
i := vleVariables.Row;
@ -3715,6 +3709,7 @@ begin
cp.center[1] := 0;
cp.zoom := 0;
cp.pixels_per_unit := PreviewImage.Width/4;
cp.FAngle := 0;
Transforms := 2;
SelectedTriangle := 1;
@ -3725,9 +3720,10 @@ begin
EnableFinalXform := false;
assert(cp.HasFinalXForm = false);
cbTransforms.clear;
cbTransforms.Items.Add('1');
cbTransforms.Items.Add('2');
// cbTransforms.clear;
// cbTransforms.Items.Add('1');
// cbTransforms.Items.Add('2');
UpdateXformsList;
AutoZoom;
UpdateFlame(True);
@ -4093,7 +4089,8 @@ procedure TEditForm.DragPanelMouseDown(Sender: TObject;
begin
if Button <> mbLeft then exit;
//assert(pnlDragMode = false);
assert(pnlDragMode = false); //?
if pnlDragMode = true then exit;
if (Sender = pnlWeight) then
if SelectedTriangle < Transforms then

View File

@ -1,5 +1,6 @@
{
Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -153,11 +154,13 @@ var
Variations: array[0..63] of boolean;
VariationOptions: int64;
MainForm_RotationMode: integer;
PreserveQuality: boolean;
{ For random gradients }
MinNodes, MaxNodes, MinHue, MaxHue, MinSat, MaxSat, MinLum, MaxLum: integer;
ReferenceMode: integer;//FixedReference: boolean;
MainForm_RotationMode: integer;
BatchSize: Integer;
Compatibility: integer; //0 = original, 1 = Drave's
Favorites: TStringList;

View File

@ -21,7 +21,9 @@ object MainForm: TMainForm
OnCreate = FormCreate
OnDestroy = FormDestroy
OnDeactivate = FormDeactivate
OnKeyDown = FormKeyUpDown
OnKeyPress = FormKeyPress
OnKeyUp = FormKeyUpDown
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13

View File

@ -39,7 +39,7 @@ const
RS_XO = 2;
RS_VO = 3;
AppVersionString = 'Apophysis 2.05 pre-release 16';
AppVersionString = 'Apophysis 2.05 pre-release 17';
type
TMouseMoveState = (msUsual, msZoomWindow, msZoomOutWindow, msZoomWindowMove,
@ -193,6 +193,8 @@ type
procedure mnuRWeightsClick(Sender: TObject);
procedure mnuRandomBatchClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyUpDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure mnuOptionsClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure mnuHelpTopicsClick(Sender: TObject);
@ -290,6 +292,7 @@ type
FViewImage: TPngObject;
FViewPos, FViewOldPos: TSPoint;
FViewScale: double;
FShiftState: TShiftState;
// For parsing:
FinalXformLoaded: boolean;
@ -2657,13 +2660,25 @@ begin
end;
procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
var
scale: double;
begin
if Key = #27 then begin
case FMouseMoveState of
msZoomWindowMove: FMouseMoveState := msZoomWindow;
msZoomOutWindowMove: FMouseMoveState := msZoomOutWindow;
msDragMove: FMouseMoveState := msDrag;
msRotateMove: FMouseMoveState := msRotate;
msZoomWindowMove:
FMouseMoveState := msZoomWindow;
msZoomOutWindowMove:
FMouseMoveState := msZoomOutWindow;
msDragMove:
begin
FMouseMoveState := msDrag;
scale := FViewScale * Image.Width / FViewImage.Width;
FViewPos.X := FViewPos.X - (FSelectRect.Right - FSelectRect.Left) / scale;
FViewPos.Y := FViewPos.Y - (FSelectRect.Bottom - FSelectRect.Top) / scale;
end;
msRotateMove:
FMouseMoveState := msRotate;
end;
DrawImageView;
end;
@ -4280,7 +4295,7 @@ procedure TMainForm.ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: In
const
snap_angle = 15*pi/180;
var
dx, dy: integer;
dx, dy, cx, cy, sgn: integer;
scale: double;
begin
{
@ -4311,15 +4326,33 @@ begin
FSelectRect.Right := FClickPos.X + dx;
FSelectRect.Bottom := FClickPos.Y + dy;
end
else begin
else if ssShift in Shift then begin
FSelectRect.Left := FClickPos.X;
FSelectRect.Top := FClickPos.Y;
sgn := IfThen(dy*dx >=0, 1, -1);
if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then begin
FSelectRect.Right := x;
FSelectRect.Bottom := FClickPos.Y + sign(dx*dy) * Round(dx / Image.Width * Image.Height);
FSelectRect.Bottom := FClickPos.Y + sgn * Round(dx / Image.Width * Image.Height);
end
else begin
FSelectRect.Right := FClickPos.X + sign(dy*dx) * Round(dy / Image.Height * Image.Width);
FSelectRect.Right := FClickPos.X + sgn * Round(dy / Image.Height * Image.Width);
FSelectRect.Bottom := y;
end;
end
else begin
sgn := IfThen(dy*dx >=0, 1, -1);
if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then begin
cy := (y + FClickPos.Y) div 2;
FSelectRect.Left := FClickPos.X;
FSelectRect.Right := x;
FSelectRect.Top := cy - sgn * Round(dx / 2 / Image.Width * Image.Height);
FSelectRect.Bottom := cy + sgn * Round(dx / 2 / Image.Width * Image.Height);
end
else begin
cx := (x + FClickPos.X) div 2;
FSelectRect.Left := cx - sgn * Round(dy / 2 / Image.Height * Image.Width);
FSelectRect.Right := cx + sgn * Round(dy / 2 / Image.Height * Image.Width);
FSelectRect.Top := FClickPos.Y;
FSelectRect.Bottom := y;
end;
end;
@ -4676,6 +4709,7 @@ begin
UpdateWindows;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.ImageDblClick(Sender: TObject);
begin
if FMouseMoveState = msRotateMove then
@ -4715,9 +4749,28 @@ begin
DrawImageView;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.tbShowTraceClick(Sender: TObject);
begin
TraceForm.Show;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.FormKeyUpDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
MousePos: TPoint;
begin
if Shift <> FShiftState then begin
if FMouseMoveState in [msZoomWindowMove, msZoomOutWindowMove, msRotateMove, msDragMove] then
begin
// hack: to generate MouseMove event
GetCursorPos(MousePos);
SetCursorPos(MousePos.x, MousePos.y);
end;
FShiftState := Shift;
end;
end;
end.

View File

@ -630,7 +630,7 @@ object OptionsForm: TOptionsForm
object rgRotationMode: TRadioGroup
Left = 8
Top = 60
Width = 121
Width = 113
Height = 61
Caption = 'Rotation Mode'
Items.Strings = (
@ -638,6 +638,17 @@ object OptionsForm: TOptionsForm
'Rotate frame')
TabOrder = 3
end
object rgZoomingMode: TRadioGroup
Left = 128
Top = 60
Width = 117
Height = 61
Caption = 'Zooming mode'
Items.Strings = (
'Preserve quality'
'Preserve speed')
TabOrder = 4
end
end
end
object RandomPage: TTabSheet

View File

@ -215,6 +215,7 @@ type
chkExtendedEdit: TCheckBox;
rgDoubleClickVars: TRadioGroup;
chkOldPaletteFormat: TCheckBox;
rgZoomingMode: TRadioGroup;
procedure btnCancelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnOKClick(Sender: TObject);
@ -305,6 +306,10 @@ begin
chkOldPaletteFormat.Checked := OldPaletteFormat;
rgRotationMode.ItemIndex := MainForm_RotationMode;
if PreserveQuality then
rgZoomingMode.ItemIndex := 0
else
rgZoomingMode.ItemIndex := 1;
txtJPEGQuality.text := IntToStr(JPEGQuality);
chkPlaySound.Checked := PlaySoundOnRenderComplete;
@ -439,6 +444,7 @@ begin
OldPaletteFormat := chkOldPaletteFormat.Checked;
MainForm_RotationMode := rgRotationMode.ItemIndex;
PreserveQuality := (rgZoomingMode.ItemIndex = 0);
// ResizeOnLoad := chkResize.checked;
InternalBitsPerSample := cbInternalBitsPerSample.ItemIndex;

View File

@ -1,5 +1,6 @@
{
Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Borys, Peter Sdobnov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -108,6 +109,14 @@ begin
begin
OldPaletteFormat := false;
end;
if Registry.ValueExists('PreserveQuality') then
begin
PreserveQuality := Registry.ReadBool('PreserveQuality');
end
else
begin
PreserveQuality := true;
end;
if Registry.ValueExists('KeepBackground') then
begin
@ -589,6 +598,7 @@ begin
mutantMinTransforms := 2;
mutantMaxTransforms := 6;
randGradient := 0;
PreserveQuality := false;
KeepBackground := False;
UPRPath := DefaultPath;
ImageFolder := DefaultPath;
@ -1045,6 +1055,7 @@ begin
// Registry.WriteBool('ResizeOnLoad', ResizeOnLoad);
Registry.WriteBool('ShowProgress', ShowProgress);
Registry.WriteBool('KeepBackground', KeepBackground);
Registry.WriteBool('PreserveQuality', PreserveQuality);
Registry.WriteString('FunctionLibrary', defLibrary);
Registry.WriteBool('ShowTransparency', ShowTransparency);

View File

@ -160,8 +160,6 @@ type
procedure SetCP(CP: TControlPoint);
procedure Render;
function GetBucketSize: integer; virtual; abstract;
function GetImage: TBitmap;
procedure Stop;