From e3d705bd3d87172b05e83b65817987cbce1d23a1 Mon Sep 17 00:00:00 2001
From: zueuk <zueuk>
Date: Thu, 5 Jan 2006 18:38:34 +0000
Subject: [PATCH] something new...:)

---
 2.10/Source/Adjust.dfm     | 17 +++++++------
 2.10/Source/Adjust.pas     | 28 ++++++++++++--------
 2.10/Source/Editor.dfm     | 42 ++++++++++++++++--------------
 2.10/Source/Editor.pas     | 52 +++++++++++++++++++++++++++++++++-----
 2.10/Source/FormRender.dfm | 16 ++++++------
 2.10/Source/FormRender.pas |  1 +
 2.10/Source/Fullscreen.dfm | 12 ++++-----
 2.10/Source/Main.dfm       | 21 +++++----------
 2.10/Source/Mutate.dfm     |  9 ++++---
 2.10/Source/Mutate.pas     |  6 ++---
 2.10/Source/ScriptForm.pas |  4 +++
 11 files changed, 129 insertions(+), 79 deletions(-)

diff --git a/2.10/Source/Adjust.dfm b/2.10/Source/Adjust.dfm
index f2f4917..4c4a3b5 100644
--- a/2.10/Source/Adjust.dfm
+++ b/2.10/Source/Adjust.dfm
@@ -1,11 +1,11 @@
 object AdjustForm: TAdjustForm
-  Left = 363
-  Top = 245
+  Left = 364
+  Top = 246
   BorderIcons = [biSystemMenu, biMinimize]
   BorderStyle = bsSingle
   Caption = 'Adjust'
-  ClientHeight = 263
-  ClientWidth = 390
+  ClientHeight = 261
+  ClientWidth = 388
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -170,10 +170,10 @@ object AdjustForm: TAdjustForm
   end
   object PageControl: TPageControl
     Left = 0
-    Top = 133
-    Width = 390
+    Top = 131
+    Width = 388
     Height = 130
-    ActivePage = TabSheet1
+    ActivePage = TabSheet2
     Align = alBottom
     TabOrder = 1
     object TabSheet1: TTabSheet
@@ -478,6 +478,7 @@ object AdjustForm: TAdjustForm
         Width = 75
         Height = 21
         TabOrder = 8
+        OnExit = editPPUValidate
         OnKeyPress = editPPUKeyPress
       end
     end
@@ -672,7 +673,7 @@ object AdjustForm: TAdjustForm
       object GradientPnl: TPanel
         Left = 0
         Top = 0
-        Width = 382
+        Width = 380
         Height = 49
         Align = alTop
         BevelOuter = bvLowered
diff --git a/2.10/Source/Adjust.pas b/2.10/Source/Adjust.pas
index bd73cd9..e7ed92a 100644
--- a/2.10/Source/Adjust.pas
+++ b/2.10/Source/Adjust.pas
@@ -250,6 +250,7 @@ type
     procedure btnApplySizeClick(Sender: TObject);
     procedure mnuInstantPreviewClick(Sender: TObject);
     procedure editPPUKeyPress(Sender: TObject; var Key: Char);
+    procedure editPPUValidate(Sender: TObject);
 
   private
     Resetting: boolean;
@@ -375,7 +376,7 @@ begin
   BackupPal := cp.cmap;
 
   Resetting := False;
-editPPU.Text := FloatToStr(cp.pixels_per_unit);
+editPPU.Text := Format('%.6g', [cp.pixels_per_unit]);
   end; //***
   DrawPreview;
 end;
@@ -1886,22 +1887,27 @@ begin
 end;
 
 procedure TAdjustForm.editPPUKeyPress(Sender: TObject; var Key: Char);
-var
-  t: double;
 begin
   if key=#13 then
   begin
     key := #0;
-    try
-      t:=strtofloat(editPPU.Text);
-    except
-      exit;
-    end;
-    MainForm.UpdateUndo;
-    cp.pixels_per_unit:=t;
-    UpdateFlame;
+    editPPUValidate(Sender);
   end;
 end;
 
+procedure TAdjustForm.editPPUValidate(Sender: TObject);
+var
+  v: double;
+begin
+  try
+    v := strtofloat(editPPU.Text);
+  except
+    exit;
+  end;
+  MainForm.UpdateUndo;
+  cp.pixels_per_unit := v;
+  UpdateFlame;
+end;
+
 end.
 
diff --git a/2.10/Source/Editor.dfm b/2.10/Source/Editor.dfm
index 4a5bb18..f0a9320 100644
--- a/2.10/Source/Editor.dfm
+++ b/2.10/Source/Editor.dfm
@@ -1,7 +1,7 @@
 object EditForm: TEditForm
-  Left = 302
-  Top = 226
-  Width = 586
+  Left = 303
+  Top = 227
+  Width = 584
   Height = 573
   Caption = 'Transform Editor'
   Color = clBtnFace
@@ -55,7 +55,7 @@ object EditForm: TEditForm
   object StatusBar: TStatusBar
     Left = 0
     Top = 530
-    Width = 578
+    Width = 576
     Height = 15
     Panels = <
       item
@@ -71,7 +71,7 @@ object EditForm: TEditForm
   object topPnl: TPanel
     Left = 0
     Top = 0
-    Width = 578
+    Width = 576
     Height = 24
     Align = alTop
     BevelOuter = bvSpace
@@ -268,12 +268,12 @@ object EditForm: TEditForm
   object EditPnl: TPanel
     Left = 0
     Top = 24
-    Width = 578
+    Width = 576
     Height = 506
     Align = alClient
     TabOrder = 1
     object Splitter1: TSplitter
-      Left = 396
+      Left = 394
       Top = 1
       Width = 9
       Height = 504
@@ -286,7 +286,7 @@ object EditForm: TEditForm
     object GrphPnl: TPanel
       Left = 1
       Top = 1
-      Width = 395
+      Width = 393
       Height = 504
       Align = alClient
       BevelOuter = bvNone
@@ -294,7 +294,7 @@ object EditForm: TEditForm
       TabOrder = 0
     end
     object RightPanel: TPanel
-      Left = 405
+      Left = 403
       Top = 1
       Width = 172
       Height = 504
@@ -367,9 +367,9 @@ object EditForm: TEditForm
         end
         object PageControl: TPageControl
           Left = 1
-          Top = 30
+          Top = 32
           Width = 170
-          Height = 335
+          Height = 333
           ActivePage = TriangleTab
           Align = alBottom
           Anchors = [akLeft, akTop, akRight, akBottom]
@@ -382,7 +382,7 @@ object EditForm: TEditForm
               Left = 0
               Top = 0
               Width = 162
-              Height = 289
+              Height = 287
               HorzScrollBar.Visible = False
               VertScrollBar.Smooth = True
               VertScrollBar.Style = ssFlat
@@ -401,7 +401,7 @@ object EditForm: TEditForm
                 TabOrder = 0
                 object LabelB: TLabel
                   Left = 4
-                  Top = 32
+                  Top = 56
                   Width = 12
                   Height = 13
                   Caption = 'O:'
@@ -415,7 +415,7 @@ object EditForm: TEditForm
                 end
                 object LabelC: TLabel
                   Left = 4
-                  Top = 56
+                  Top = 32
                   Width = 10
                   Height = 13
                   Caption = 'Y:'
@@ -932,7 +932,7 @@ object EditForm: TEditForm
                 end
                 object txtCy: TEdit
                   Left = 88
-                  Top = 52
+                  Top = 28
                   Width = 65
                   Height = 21
                   AutoSelect = False
@@ -943,7 +943,7 @@ object EditForm: TEditForm
                 end
                 object txtCx: TEdit
                   Left = 20
-                  Top = 52
+                  Top = 28
                   Width = 65
                   Height = 21
                   AutoSelect = False
@@ -954,7 +954,7 @@ object EditForm: TEditForm
                 end
                 object txtBy: TEdit
                   Left = 88
-                  Top = 28
+                  Top = 52
                   Width = 65
                   Height = 21
                   AutoSelect = False
@@ -965,7 +965,7 @@ object EditForm: TEditForm
                 end
                 object txtBx: TEdit
                   Left = 20
-                  Top = 28
+                  Top = 52
                   Width = 65
                   Height = 21
                   AutoSelect = False
@@ -1008,6 +1008,7 @@ object EditForm: TEditForm
                   Text = '0.1'
                   OnExit = txtValidateValue
                   OnKeyPress = txtValKeyPress
+                  OnSelect = txtValidateValue
                   Items.Strings = (
                     '1'
                     '0.5'
@@ -1028,6 +1029,7 @@ object EditForm: TEditForm
                   Text = '15'
                   OnExit = txtValidateValue
                   OnKeyPress = txtValKeyPress
+                  OnSelect = txtValidateValue
                   Items.Strings = (
                     '5'
                     '15'
@@ -1050,6 +1052,7 @@ object EditForm: TEditForm
                   Text = '125'
                   OnExit = txtValidateValue
                   OnKeyPress = txtValKeyPress
+                  OnSelect = txtValidateValue
                   Items.Strings = (
                     '110'
                     '125'
@@ -1525,8 +1528,9 @@ object EditForm: TEditForm
                 ItemIndex = 0
                 TabOrder = 3
                 Text = '0'
-                OnExit = txtSymmetryExit
+                OnExit = txtSymmetrySet
                 OnKeyPress = txtSymmetryKeyPress
+                OnSelect = txtSymmetrySet
                 Items.Strings = (
                   '0'
                   '1')
diff --git a/2.10/Source/Editor.pas b/2.10/Source/Editor.pas
index a8267e9..b464b72 100644
--- a/2.10/Source/Editor.pas
+++ b/2.10/Source/Editor.pas
@@ -28,7 +28,7 @@ uses
 
 const
 //  PixelCountMax = 32768;
-  WM_PTHREAD_COMPLETE = WM_APP + 5438;
+//  WM_PTHREAD_COMPLETE = WM_APP + 5438;
 
   crEditArrow = 20;
   crEditMove = 21;
@@ -222,7 +222,7 @@ type
     procedure chkHelpersClick(Sender: TObject);
     procedure txtXFormColorExit(Sender: TObject);
     procedure txtXFormColorKeyPress(Sender: TObject; var Key: Char);
-    procedure txtSymmetryExit(Sender: TObject);
+    procedure txtSymmetrySet(Sender: TObject);
     procedure txtSymmetryKeyPress(Sender: TObject; var Key: Char);
 
     procedure btTrgRotateLeftClick(Sender: TObject);
@@ -305,6 +305,7 @@ type
 
     MousePos: TPoint; // in screen coordinates
     mouseOverTriangle, mouseOverCorner: integer;
+    mouseOverPos: TSPoint;
 
     varDragMode: boolean;
     varDragIndex :integer;
@@ -1326,7 +1327,15 @@ end;
       Pen.Style := psSolid;
       pen.Color := clWhite;
       brush.Color := clSilver;
-      Ellipse(a.x - 2, a.y - 2, a.x + 2, a.y + 2);
+      if pivotMode = pivotLocal then i := 2
+      else i := 3;
+      Ellipse(a.x - i, a.y - i, a.x + i, a.y + i);
+
+      if editMode = modePick then begin // hmm...
+        a := ToScreen(mouseOverPos.x, mouseOverPos.y);
+        brush.Style := bsClear;
+        Ellipse(a.x - i, a.y - i, a.x + i, a.y + i);
+      end;
 
       if TWinControl(Sender).Focused then
       begin
@@ -1371,7 +1380,7 @@ begin
 
   TriangleView.OnPaint := TriangleViewPaint;
 
-  TriangleView.OnDblClick   := mnuAutoZoomClick;//TriangleViewDblClick;
+  TriangleView.OnDblClick   := mnuAutoZoomClick;
   TriangleView.OnMouseDown  := TriangleViewMouseDown;
   TriangleView.OnMouseMove  := TriangleViewMouseMove;
   TriangleView.OnMouseUp    := TriangleViewMouseUp;
@@ -1494,10 +1503,19 @@ begin
     olddist := Hypot(oldx, oldy);
 // --
 
+// -- for Pick Pivot
+    if editMode = modePick then
+    begin
+      mouseOverPos.x := MainTriangles[mouseOverTriangle].x[mouseOverCorner];
+      mouseOverPos.y := MainTriangles[mouseOverTriangle].y[mouseOverCorner];
+    end;
+// ---
           goto FoundCorner;
         end;
       end;
     mouseOverCorner:=-1;
+    mouseOverPos.x := fx;
+    mouseOverPos.y := fy;
 
     i := InsideTriangle(fx, fy);
     if i >= 0 then mouseOverTriangle:=i
@@ -1719,6 +1737,7 @@ Skip2:
     else StatusBar.Panels[2].Text := '';
     TriangleView.Refresh;
   end
+  else if editMode = modePick then TriangleView.Refresh; // hmm...
 end;
 
 procedure TEditForm.TriangleViewMouseDown(Sender: TObject; Button: TMouseButton;
@@ -1736,6 +1755,11 @@ begin
 
   if editMode = modePick then
   begin
+    if (mouseOverCorner >= 0) then // snap to point
+    begin
+      fx := MainTriangles[mouseOverTriangle].x[mouseOverCorner];
+      fy := MainTriangles[mouseOverTriangle].y[mouseOverCorner];
+    end;
     if PivotMode = pivotLocal then
     with MainTriangles[SelectedTriangle] do begin
       LocalPivot.x :=
@@ -2637,7 +2661,7 @@ begin
   end;
 end;
 
-procedure TEditForm.txtSymmetryExit(Sender: TObject);
+procedure TEditForm.txtSymmetrySet(Sender: TObject);
 var
   Allow: boolean;
   NewVal, OldVal: double;
@@ -3183,6 +3207,10 @@ begin
     VK_END: btTrgScaleDownClick(Sender);
     VK_INSERT: mnuDupClick(Sender);
     VK_DELETE: mnuDeleteClick(Sender);
+
+    // can be changed in the future...
+    Ord('R'): btnResetPivotClick(Sender);
+    Ord('P'): btnPickPivotClick(Sender);
   end;
 end;
 
@@ -3724,6 +3752,14 @@ end;
 
 procedure TEditForm.btnResetPivotClick(Sender: TObject);
 begin
+  if editMode = modePick then begin
+    editMode := oldMode;
+    oldMode := modeNone;
+    // hack: to generate MouseMove event
+    GetCursorPos(MousePos);
+    SetCursorPos(MousePos.x, MousePos.y);
+    //
+  end;
   if PivotMode = pivotLocal then
   begin
     LocalPivot.x := 0;
@@ -3742,12 +3778,16 @@ begin
   if editMode = modePick then begin
     editMode := oldMode;
     oldMode := modeNone;
+    // hack: to generate MouseMove event
+    GetCursorPos(MousePos);
+    SetCursorPos(MousePos.x, MousePos.y);
+    //
     exit;
   end;
   if oldMode <> modeNone then exit;
   oldMode := editMode;
   editMode := modePick;
-  TriangleView.Cursor := crCross; //...
+  //TriangleView.Cursor := crCross; //...
   btnPickPivot.Down := true;
 end;
 
diff --git a/2.10/Source/FormRender.dfm b/2.10/Source/FormRender.dfm
index 53badb6..9a4722a 100644
--- a/2.10/Source/FormRender.dfm
+++ b/2.10/Source/FormRender.dfm
@@ -1,11 +1,11 @@
 object RenderForm: TRenderForm
-  Left = 286
-  Top = 251
+  Left = 287
+  Top = 252
   BorderIcons = [biSystemMenu, biMinimize]
   BorderStyle = bsSingle
   Caption = 'RenderForm'
-  ClientHeight = 416
-  ClientWidth = 424
+  ClientHeight = 414
+  ClientWidth = 422
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -51,8 +51,8 @@ object RenderForm: TRenderForm
   TextHeight = 13
   object ProgressBar: TProgressBar
     Left = 0
-    Top = 384
-    Width = 424
+    Top = 382
+    Width = 422
     Height = 13
     Align = alBottom
     TabOrder = 0
@@ -437,8 +437,8 @@ object RenderForm: TRenderForm
   end
   object StatusBar: TStatusBar
     Left = 0
-    Top = 397
-    Width = 424
+    Top = 395
+    Width = 422
     Height = 19
     Panels = <
       item
diff --git a/2.10/Source/FormRender.pas b/2.10/Source/FormRender.pas
index 7d675d9..f8c5f30 100644
--- a/2.10/Source/FormRender.pas
+++ b/2.10/Source/FormRender.pas
@@ -704,6 +704,7 @@ begin
   end;
   ImageWidth := StrToInt(cbWidth.Text);
   ImageHeight := StrToInt(cbHeight.Text);
+  Sample_Density := StrToFloat(txtDensity.Text);
   ShowMemoryStatus;
 end;
 
diff --git a/2.10/Source/Fullscreen.dfm b/2.10/Source/Fullscreen.dfm
index 86be5c8..8d18b90 100644
--- a/2.10/Source/Fullscreen.dfm
+++ b/2.10/Source/Fullscreen.dfm
@@ -1,10 +1,10 @@
 object FullscreenForm: TFullscreenForm
-  Left = 438
-  Top = 324
+  Left = 439
+  Top = 325
   BorderStyle = bsNone
   Caption = 'FullscreenForm'
-  ClientHeight = 133
-  ClientWidth = 188
+  ClientHeight = 131
+  ClientWidth = 186
   Color = clBlack
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -22,8 +22,8 @@ object FullscreenForm: TFullscreenForm
   object Image: TImage
     Left = 0
     Top = 0
-    Width = 188
-    Height = 133
+    Width = 186
+    Height = 131
     Align = alClient
     OnDblClick = ImageDblClick
   end
diff --git a/2.10/Source/Main.dfm b/2.10/Source/Main.dfm
index 0823521..4da8219 100644
--- a/2.10/Source/Main.dfm
+++ b/2.10/Source/Main.dfm
@@ -1,7 +1,7 @@
 object MainForm: TMainForm
-  Left = 400
-  Top = 157
-  Width = 731
+  Left = 401
+  Top = 158
+  Width = 729
   Height = 530
   Caption = 'Apophysis'
   Color = clBtnFace
@@ -34,7 +34,7 @@ object MainForm: TMainForm
   object ToolBar: TToolBar
     Left = 0
     Top = 0
-    Width = 723
+    Width = 721
     Height = 28
     BorderWidth = 1
     Flat = True
@@ -116,9 +116,7 @@ object MainForm: TMainForm
       Hint = 'Rendering quality|Rendering quality of the main window'
       AutoComplete = False
       ItemHeight = 13
-      ItemIndex = 0
       TabOrder = 0
-      Text = '5'
       OnExit = tbQualityBoxSet
       OnKeyPress = tbQualityBoxKeyPress
       OnSelect = tbQualityBoxSet
@@ -306,7 +304,7 @@ object MainForm: TMainForm
   object BackPanel: TPanel
     Left = 164
     Top = 28
-    Width = 559
+    Width = 557
     Height = 435
     Align = alClient
     BevelInner = bvLowered
@@ -317,7 +315,7 @@ object MainForm: TMainForm
     object Image: TImage
       Left = 1
       Top = 1
-      Width = 557
+      Width = 555
       Height = 433
       Align = alClient
       AutoSize = True
@@ -332,7 +330,7 @@ object MainForm: TMainForm
   object StatusBar: TStatusBar
     Left = 0
     Top = 463
-    Width = 723
+    Width = 721
     Height = 19
     Panels = <
       item
@@ -2485,7 +2483,6 @@ object MainForm: TMainForm
     Top = 56
     object MainFile: TMenuItem
       Caption = '&File'
-      Hint = 'Contains commands for working with files'
       OnClick = MainFileClick
       object mnuOpen: TMenuItem
         Caption = '&Open...'
@@ -2575,7 +2572,6 @@ object MainForm: TMainForm
     end
     object MainEdit: TMenuItem
       Caption = '&Edit'
-      Hint = 'Contains edit commands'
       object mnuUndo: TMenuItem
         Caption = '&Undo'
         Enabled = False
@@ -2682,7 +2678,6 @@ object MainForm: TMainForm
     end
     object F1: TMenuItem
       Caption = 'Flame'
-      Hint = 'Contains commands for manipulating the flame'
       object mnuResetLocation: TMenuItem
         Caption = 'Reset Location'
         Hint = 'Recalculate flame location'
@@ -2740,7 +2735,6 @@ object MainForm: TMainForm
     end
     object mnuVar: TMenuItem
       Caption = 'Variation'
-      Hint = 'Set the flame variation to use'
       object mnuVRandom: TMenuItem
         Caption = 'Random'
         Checked = True
@@ -2797,7 +2791,6 @@ object MainForm: TMainForm
     end
     object mnuView: TMenuItem
       Caption = 'Options'
-      Hint = 'Contains commands for customizing Apophysis'
       object mnuToolbar: TMenuItem
         Caption = 'Toolbar'
         Checked = True
diff --git a/2.10/Source/Mutate.dfm b/2.10/Source/Mutate.dfm
index 7013f1d..c43819d 100644
--- a/2.10/Source/Mutate.dfm
+++ b/2.10/Source/Mutate.dfm
@@ -1,11 +1,11 @@
 object MutateForm: TMutateForm
-  Left = 857
-  Top = 311
+  Left = 858
+  Top = 312
   BorderIcons = [biSystemMenu, biMinimize]
   BorderStyle = bsSingle
   Caption = 'Mutation'
-  ClientHeight = 383
-  ClientWidth = 372
+  ClientHeight = 381
+  ClientWidth = 370
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -285,6 +285,7 @@ object MutateForm: TMutateForm
       Width = 145
       Height = 21
       Style = csDropDownList
+      DropDownCount = 16
       ItemHeight = 13
       TabOrder = 1
       OnChange = cmbTrendChange
diff --git a/2.10/Source/Mutate.pas b/2.10/Source/Mutate.pas
index a1fb66e..7c15adf 100644
--- a/2.10/Source/Mutate.pas
+++ b/2.10/Source/Mutate.pas
@@ -121,9 +121,9 @@ begin
   MainCp.Copy(cps[0]);
   Transforms := MainCp.TrianglesFromCP(MainTriangles);
   MainCp.cmap := cmap;
-  MainCp.name := name;
-  MainCp.nick := nick;
-  mainCp.url := url;
+  MainCp.name := name; // this is kinda funny,
+  MainCp.nick := nick; // like author's nick can change during mutation?
+  mainCp.url := url;   // hee-heheee :-)
   if mnuResetLocation.checked then
   begin
     MainForm.Mainzoom := cps[0].zoom;
diff --git a/2.10/Source/ScriptForm.pas b/2.10/Source/ScriptForm.pas
index f20d7db..07d1788 100644
--- a/2.10/Source/ScriptForm.pas
+++ b/2.10/Source/ScriptForm.pas
@@ -2713,6 +2713,9 @@ begin
   Scripter.AddConstant('V_COSINE', 20);
   Scripter.AddConstant('V_RINGS', 21);
   Scripter.AddConstant('V_FAN', 22);
+  Scripter.AddConstant('V_EYEFISH', 23);
+  Scripter.AddConstant('V_BUBBLE', 24);
+  Scripter.AddConstant('V_CYLINDER', 25);
   Scripter.AddConstant('V_RANDOM', -1);
   { Variables }
   Scripter.AddVariable('SelectedTransform', EditForm.SelectedTriangle);
@@ -2979,6 +2982,7 @@ begin
   dest.c[2, 0] := source.c[2, 0];
   dest.c[2, 1] := source.c[2, 1];
   dest.color := source.color;
+// hmm, why no symmetry here? // dest.symmetry := source.symmetry;
   dest.density := source.density;
   for i := 0 to NRVAR - 1 do
     dest.vars[i] := source.vars[i];