From 9d535966a29831fe9322fa784be48ba3b5a3927c Mon Sep 17 00:00:00 2001 From: zueuk Date: Sat, 25 Mar 2006 17:36:12 +0000 Subject: [PATCH] double-clicking on variables now resets them to some default value instead of just '0' --- 2.10/Source/BaseVariation.pas | 13 +++++++++++-- 2.10/Source/XForm.pas | 15 ++++++++++++--- 2.10/Source/varJuliaN.pas | 15 +++++++++++++++ 2.10/Source/varJuliaScope.pas | 14 ++++++++++++++ 2.10/Source/varPerspective.pas | 14 ++++++++++++++ 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/2.10/Source/BaseVariation.pas b/2.10/Source/BaseVariation.pas index 211af5f..cbd4ec1 100644 --- a/2.10/Source/BaseVariation.pas +++ b/2.10/Source/BaseVariation.pas @@ -7,7 +7,9 @@ type type TBaseVariation = class + protected + procedure CalcFunction; virtual; abstract; public vvar: double; // normalized interp coefs between variations @@ -22,10 +24,10 @@ type function SetVariable(const Name: string; var value: double): boolean; virtual; function GetVariable(const Name: string; var value: double): boolean; virtual; + function ResetVariable(const Name: string): boolean; virtual; procedure Prepare; virtual; - procedure CalcFunction; virtual; abstract; procedure GetCalcFunction(var Delphi_Suxx: TCalcFunction); virtual; end; @@ -54,12 +56,19 @@ begin Result := False; end; -/////////////////////////////////////////////////////////////////////////////// class function TBaseVariation.GetVariableNameAt(const Index: integer): string; begin Result := '' end; +function TBaseVariation.ResetVariable(const Name: string): boolean; +var + zero: double; +begin + zero := 0; + Result := SetVariable(Name, zero); +end; + /////////////////////////////////////////////////////////////////////////////// procedure TBaseVariation.Prepare; begin diff --git a/2.10/Source/XForm.pas b/2.10/Source/XForm.pas index 7ac1bd6..43ede97 100644 --- a/2.10/Source/XForm.pas +++ b/2.10/Source/XForm.pas @@ -127,6 +127,7 @@ type procedure SetVariable(const name: string; var Value: double); procedure GetVariable(const name: string; var Value: double); + procedure ResetVariable(const name: string); function ToXMLString: string; function FinalToXMLString(IsEnabled: boolean): string; @@ -1950,8 +1951,8 @@ begin FFunctionList[28] := Focus; //registered - for i := 0 to High(FRegVariations) do - FFunctionList[NRLOCVAR + i] := FRegVariations[i].CalcFunction; +// for i := 0 to High(FRegVariations) do +// FFunctionList[NRLOCVAR + i] := FRegVariations[i].CalcFunction; end; /////////////////////////////////////////////////////////////////////////////// @@ -2061,7 +2062,6 @@ begin break; end; -/////////////////////////////////////////////////////////////////////////////// procedure TXForm.GetVariable(const name: string; var Value: double); var i: integer; @@ -2071,5 +2071,14 @@ begin break; end; +procedure TXForm.ResetVariable(const name: string); +var + i: integer; +begin + for i := 0 to High(FRegVariations) do + if FRegVariations[i].ResetVariable(name) then + break; +end; + /////////////////////////////////////////////////////////////////////////////// end. diff --git a/2.10/Source/varJuliaN.pas b/2.10/Source/varJuliaN.pas index 6b5d416..292e7a9 100644 --- a/2.10/Source/varJuliaN.pas +++ b/2.10/Source/varJuliaN.pas @@ -36,6 +36,7 @@ type function SetVariable(const Name: string; var value: double): boolean; override; function GetVariable(const Name: string; var value: double): boolean; override; + function ResetVariable(const Name: string): boolean; override; procedure Prepare; override; procedure CalcFunction; override; @@ -343,6 +344,20 @@ begin end else if Name = var_c_name then begin c := value; + Result := True; + end; +end; + +function TVariationJulian.ResetVariable(const Name: string): boolean; +begin + Result := False; + if Name = var_n_name then begin + N := 2; + Result := True; + end + else if Name = var_c_name then begin + c := 1; + Result := True; end; end; diff --git a/2.10/Source/varJuliaScope.pas b/2.10/Source/varJuliaScope.pas index 52c3689..1fe99cc 100644 --- a/2.10/Source/varJuliaScope.pas +++ b/2.10/Source/varJuliaScope.pas @@ -37,6 +37,7 @@ type function SetVariable(const Name: string; var value: double): boolean; override; function GetVariable(const Name: string; var value: double): boolean; override; + function ResetVariable(const Name: string): boolean; override; procedure Prepare; override; procedure CalcFunction; override; @@ -390,6 +391,19 @@ begin end; end; +function TVariationJuliaScope.ResetVariable(const Name: string): boolean; +begin + Result := False; + if Name = var_n_name then begin + N := 2; + Result := True; + end + else if Name = var_c_name then begin + c := 1; + Result := True; + end; +end; + /////////////////////////////////////////////////////////////////////////////// class function TVariationJuliaScope.GetNrVariables: integer; begin diff --git a/2.10/Source/varPerspective.pas b/2.10/Source/varPerspective.pas index 0e672f2..d928aeb 100644 --- a/2.10/Source/varPerspective.pas +++ b/2.10/Source/varPerspective.pas @@ -26,6 +26,7 @@ type function SetVariable(const Name: string; var value: double): boolean; override; function GetVariable(const Name: string; var value: double): boolean; override; + function ResetVariable(const Name: string): boolean; override; procedure CalcFunction; override; procedure Prepare; override; @@ -119,6 +120,19 @@ begin end end; +function TVariationPerspective.ResetVariable(const Name: string): boolean; +begin + Result := False; + if Name = var_a_name then begin + angle := 0; + Result := True; + end + else if Name = var_f_name then begin + focus := 2; + Result := True; + end; +end; + /////////////////////////////////////////////////////////////////////////////// class function TVariationPerspective.GetNrVariables: integer; begin