From fdca7e4134f01ebb76dd251eddb9a723bd6ab742 Mon Sep 17 00:00:00 2001 From: zueuk Date: Mon, 29 Sep 2008 07:33:47 +0000 Subject: [PATCH] new editor option : rebuild xaos links (after deleting xform) --- 2.10/Source/Editor.dfm | 6 ++++ 2.10/Source/Editor.pas | 76 ++++++++++++++++++++++++----------------- 2.10/Source/Global.pas | 11 +++++- 2.10/Source/Options.dfm | 14 ++++++-- 2.10/Source/Options.pas | 3 ++ 2.10/Source/Regstry.pas | 17 +++++---- 6 files changed, 86 insertions(+), 41 deletions(-) diff --git a/2.10/Source/Editor.dfm b/2.10/Source/Editor.dfm index 2b1009d..b03bbb7 100644 --- a/2.10/Source/Editor.dfm +++ b/2.10/Source/Editor.dfm @@ -3084,6 +3084,12 @@ object EditForm: TEditForm RadioItem = True OnClick = mnuChaosViewFromClick end + object mnuChaosRebuild: TMenuItem + Caption = 'Rebuild xaos links' + Checked = True + Hint = 'Rebuild xaos links when deleting transforms' + OnClick = mnuChaosRebuildClick + end object N9: TMenuItem Caption = '-' end diff --git a/2.10/Source/Editor.pas b/2.10/Source/Editor.pas index 2849441..6bf6195 100644 --- a/2.10/Source/Editor.pas +++ b/2.10/Source/Editor.pas @@ -201,6 +201,7 @@ type GroupBox4: TGroupBox; chkXformInvisible: TCheckBox; chkXformSolo: TCheckBox; + mnuChaosRebuild: TMenuItem; procedure ValidateVariable; procedure vleVariablesValidate(Sender: TObject; ACol, ARow: Integer; const KeyName, KeyValue: string); @@ -358,6 +359,7 @@ type procedure mnuChaosSetAllClick(Sender: TObject); procedure mnuLinkPostxformClick(Sender: TObject); procedure chkXformSoloClick(Sender: TObject); + procedure mnuChaosRebuildClick(Sender: TObject); // procedure btnInvisibleClick(Sender: TObject); // procedure btnSoloClick(Sender: TObject); @@ -836,6 +838,7 @@ begin chkXformInvisible.Enabled := true; chkXformInvisible.Checked := noPlot; chkXformSolo.Enabled := true; + if cp.soloXform >= 0 then begin chkXformSolo.Checked := true; chkXformSolo.Caption := Format('Solo transform #%d', [cp.soloXform + 1]); @@ -852,8 +855,6 @@ begin chkXformInvisible.Enabled := false; chkXformInvisible.Checked := false; chkXformSolo.Enabled := false; -// chkRetrace.Checked := true; -// chkRetrace.Enabled := false; end; tbEnableFinalXform.Down := EnableFinalXform; @@ -1056,38 +1057,42 @@ begin if (Transforms <= 1) then exit else begin MainForm.UpdateUndo; - // check for single "to" links - for i := 0 to Transforms-1 do - with cp.xform[i] do begin - nmin := NXFORMS; - nmax := -1; - for j := 0 to Transforms-1 do - if modWeights[j] <> 0 then begin - if j < nmin then nmin := j; - if j > nmax then nmax := j; - end; - if (nmin = nmax) and (nmin = t) then begin + + if RebuildXaosLinks then begin + // check for single "to" links + for i := 0 to Transforms-1 do + with cp.xform[i] do begin + nmin := NXFORMS; + nmax := -1; for j := 0 to Transforms-1 do - modWeights[j] := cp.xform[t].modWeights[j]; - if noPlot then noPlot := cp.xform[t].noPlot; - end; - end; - // check for single "from" links - for i := 0 to Transforms-1 do - begin - if cp.xform[t].modWeights[i] = 0 then continue; - nmin := NXFORMS; - nmax := -1; - for j := 0 to Transforms-1 do - if cp.xform[j].modWeights[i] <> 0 then begin - if j < nmin then nmin := j; - if j > nmax then nmax := j; - end; - if (nmin = nmax) and (nmin = t) then begin - for j := 0 to Transforms-1 do - cp.xform[j].modWeights[i] := cp.xform[t].modWeights[i]; + if modWeights[j] <> 0 then begin + if j < nmin then nmin := j; + if j > nmax then nmax := j; + end; + if (nmin = nmax) and (nmin = t) then begin + for j := 0 to Transforms-1 do + modWeights[j] := cp.xform[t].modWeights[j]; + if noPlot then noPlot := cp.xform[t].noPlot; + end; + end; + // check for single "from" links + for i := 0 to Transforms-1 do + begin + if cp.xform[t].modWeights[i] = 0 then continue; + nmin := NXFORMS; + nmax := -1; + for j := 0 to Transforms-1 do + if cp.xform[j].modWeights[i] <> 0 then begin + if j < nmin then nmin := j; + if j > nmax then nmax := j; + end; + if (nmin = nmax) and (nmin = t) then begin + for j := 0 to Transforms-1 do + cp.xform[j].modWeights[i] := cp.xform[t].modWeights[i]; + end; end; end; + // delete xform from all probability tables for i := 0 to Transforms-1 do with cp.xform[i] do begin @@ -1095,7 +1100,7 @@ begin modWeights[j] := modWeights[j+1]; modWeights[Transforms-1] := 1; end; - // + if t = (Transforms - 1) then begin MainTriangles[t] := MainTriangles[Transforms]; @@ -1710,6 +1715,7 @@ begin end; vleChaos.InsertRow('to 1', '1', true); + mnuChaosRebuild.Checked := RebuildXaosLinks; GraphZoom := 1; @@ -5081,5 +5087,11 @@ begin end; } +procedure TEditForm.mnuChaosRebuildClick(Sender: TObject); +begin + RebuildXaosLinks := not RebuildXaosLinks; + mnuChaosRebuild.Checked := RebuildXaosLinks; +end; + end. diff --git a/2.10/Source/Global.pas b/2.10/Source/Global.pas index 3c7935c..82dd088 100644 --- a/2.10/Source/Global.pas +++ b/2.10/Source/Global.pas @@ -95,7 +95,7 @@ var HelpersEnabled: boolean; EditorBkgColor, ReferenceTriangleColor: integer; GridColor1, GridColor2, HelpersColor: integer; - ExtEditEnabled, TransformAxisLock: boolean; + ExtEditEnabled, TransformAxisLock, RebuildXaosLinks: boolean; ShowAllXforms: boolean; { Display } @@ -357,6 +357,15 @@ begin Result := str; end; +procedure SinCos(const Theta: double; var Sin, Cos: double); // to avoid using 'extended' type +asm + FLD Theta + FSINCOS + FSTP qword ptr [edx] // Cos + FSTP qword ptr [eax] // Sin + FWAIT +end; + (* { Palette and gradient functions } diff --git a/2.10/Source/Options.dfm b/2.10/Source/Options.dfm index 9a1afa1..206021d 100644 --- a/2.10/Source/Options.dfm +++ b/2.10/Source/Options.dfm @@ -405,7 +405,7 @@ object OptionsForm: TOptionsForm end object rgReferenceMode: TRadioGroup Left = 160 - Top = 76 + Top = 108 Width = 145 Height = 69 Caption = 'Reference Triangle' @@ -421,7 +421,7 @@ object OptionsForm: TOptionsForm Left = 160 Top = 4 Width = 145 - Height = 65 + Height = 85 Caption = 'Editor defaults' TabOrder = 2 object chkAxisLock: TCheckBox @@ -444,6 +444,16 @@ object OptionsForm: TOptionsForm State = cbChecked TabOrder = 1 end + object chkXaosRebuild: TCheckBox + Left = 8 + Top = 58 + Width = 129 + Height = 17 + Caption = 'Rebuild xaos links' + Checked = True + State = cbChecked + TabOrder = 2 + end end end object DisplayPage: TTabSheet diff --git a/2.10/Source/Options.pas b/2.10/Source/Options.pas index d465ec8..66bc1f0 100644 --- a/2.10/Source/Options.pas +++ b/2.10/Source/Options.pas @@ -222,6 +222,7 @@ type cbInternalBitsPerSample: TComboBox; txtGammaThreshold: TEdit; lblGammaThreshold: TLabel; + chkXaosRebuild: TCheckBox; procedure btnCancelClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure btnOKClick(Sender: TObject); @@ -333,6 +334,7 @@ begin chkHelpers.Checked := HelpersEnabled; chkExtendedEdit.Checked := ExtEditEnabled; chkAxisLock.Checked := TransformAxisLock; + chkXaosRebuild.Checked := RebuildXaosLinks; chkShowAllXforms.Checked := ShowAllXforms; { Display tab } @@ -472,6 +474,7 @@ begin ExtEditEnabled := chkExtendedEdit.Checked; TransformAxisLock := chkAxisLock.Checked; + RebuildXaosLinks := chkXaosRebuild.Checked; { Display tab } defSampleDensity := StrToFloat(txtSampleDensity.Text); diff --git a/2.10/Source/Regstry.pas b/2.10/Source/Regstry.pas index d0c05f1..24c98e0 100644 --- a/2.10/Source/Regstry.pas +++ b/2.10/Source/Regstry.pas @@ -567,11 +567,11 @@ begin end else begin ShowRenderStats := false; end; - if Registry.ValueExists('LowerRenderPriority') then begin - LowerRenderPriority := Registry.ReadBool('LowerRenderPriority'); - end else begin - LowerRenderPriority := false; - end; +// if Registry.ValueExists('LowerRenderPriority') then begin +// LowerRenderPriority := Registry.ReadBool('LowerRenderPriority'); +// end else begin +// LowerRenderPriority := false; +// end; if Registry.ValueExists('PNGTransparency') then begin PNGTransparency := Registry.ReadInteger('PNGTransparency'); @@ -681,7 +681,7 @@ begin // ResizeOnLoad := False; ShowProgress := true; SaveIncompleteRenders := false; - LowerRenderPriority := false; +// LowerRenderPriority := false; ShowRenderStats := false; PNGTransparency := 1; ShowTransparency := False; @@ -753,6 +753,9 @@ begin if Registry.ValueExists('LockTransformAxis') then TransformAxisLock := Registry.ReadBool('LockTransformAxis') else TransformAxisLock := true; + if Registry.ValueExists('RebuildXaosLinks') then + RebuildXaosLinks := Registry.ReadBool('RebuildXaosLinks') + else RebuildXaosLinks := true; end else begin UseTransformColors := false; @@ -765,6 +768,7 @@ begin ReferenceTriangleColor := integer(clGray); ExtEditEnabled := true; TransformAxisLock := true; + RebuildXaosLinks := true; end; Registry.CloseKey; @@ -1171,6 +1175,7 @@ begin Registry.WriteInteger('ReferenceTriangleColor', ReferenceTriangleColor); Registry.WriteBool('ExtendedEdit', ExtEditEnabled); Registry.WriteBool('LockTransformAxis', TransformAxisLock); + Registry.WriteBool('RebuildXaosLinks', RebuildXaosLinks); end; Registry.CloseKey;