apophysis/2.10/Source/XFormMan.pas

136 lines
3.1 KiB
ObjectPascal
Raw Normal View History

2005-09-11 06:30:54 -04:00
unit XFormMan;
interface
uses
BaseVariation;
const
NRLOCVAR = 29;
2005-09-11 06:30:54 -04:00
function NrVar: integer;
function Varnames(const index: integer): String;
2008-02-24 07:43:30 -05:00
procedure RegisterVariation(Variation: TVariationLoader);
2005-09-11 06:30:54 -04:00
function GetNrRegisteredVariations: integer;
2008-02-24 07:43:30 -05:00
function GetRegisteredVariation(const Index: integer): TVariationLoader;
2005-09-11 06:30:54 -04:00
function GetNrVariableNames: integer;
function GetVariableNameAt(const Index: integer): string;
function GetVariationIndex(const str: string): integer;
2005-09-11 06:30:54 -04:00
implementation
uses
Classes;
var
VariationList: TList;
VariableNames: TStringlist;
2008-02-24 07:43:30 -05:00
loaderNum : integer;
2005-09-11 06:30:54 -04:00
///////////////////////////////////////////////////////////////////////////////
function NrVar: integer;
begin
Result := NRLOCVAR + VariationList.Count;
end;
///////////////////////////////////////////////////////////////////////////////
function Varnames(const index: integer): String;
const
cvarnames: array[0..NRLOCVAR-1] of string = (
'linear',
'sinusoidal',
'spherical',
'swirl',
'horseshoe',
'polar',
'handkerchief',
'heart',
'disc',
'spiral',
'hyperbolic',
'diamond',
'ex',
'julia',
'bent',
'waves',
'fisheye',
'popcorn',
'exponential',
'power',
'cosine',
'rings',
'fan',
'eyefish',
'bubble',
'cylinder',
'noise',
'blur',
'gaussian_blur'
2005-09-11 06:30:54 -04:00
);
begin
if Index < NRLOCVAR then
Result := cvarnames[Index]
else
2008-02-24 07:43:30 -05:00
Result := TVariationLoader(VariationList[Index - NRLOCVAR]).GetName;
2005-09-11 06:30:54 -04:00
end;
///////////////////////////////////////////////////////////////////////////////
function GetVariationIndex(const str: string): integer;
var
i: integer;
begin
i := NRVAR-1;
while (i >= 0) and (Varnames(i) <> str) do Dec(i);
Result := i;
end;
2005-09-11 06:30:54 -04:00
///////////////////////////////////////////////////////////////////////////////
2008-02-24 07:43:30 -05:00
procedure RegisterVariation(Variation: TVariationLoader);
2005-09-11 06:30:54 -04:00
var
i: integer;
begin
VariationList.Add(Variation);
for i := 0 to Variation.GetNrVariables - 1 do
VariableNames.Add(Variation.GetVariableNameAt(i))
end;
///////////////////////////////////////////////////////////////////////////////
function GetNrRegisteredVariations: integer;
begin
Result := VariationList.count;
end;
///////////////////////////////////////////////////////////////////////////////
2008-02-24 07:43:30 -05:00
function GetRegisteredVariation(const Index: integer): TVariationLoader;
2005-09-11 06:30:54 -04:00
begin
2008-02-24 07:43:30 -05:00
Result := TVariationLoader(VariationList[Index]);
2005-09-11 06:30:54 -04:00
end;
///////////////////////////////////////////////////////////////////////////////
function GetNrVariableNames: integer;
begin
Result := VariableNames.Count;
end;
///////////////////////////////////////////////////////////////////////////////
function GetVariableNameAt(const Index: integer): string;
begin
Result := VariableNames[Index];
end;
///////////////////////////////////////////////////////////////////////////////
initialization
VariationList := TList.Create;
VariableNames := TStringlist.create;
2008-02-24 07:43:30 -05:00
2005-09-11 06:30:54 -04:00
finalization
2008-02-24 07:43:30 -05:00
2005-09-11 06:30:54 -04:00
VariableNames.Free;
2008-02-24 07:43:30 -05:00
// The registered variation loaders are owned here, so we must free them.
for loaderNum := 0 to VariationList.Count-1 do
TVariationLoader(VariationList[loaderNum]).Free;
2005-09-11 06:30:54 -04:00
VariationList.Free;
end.