1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-08-13 16:53:59 -04:00

Merge ssh://villavu.com:54367/simba

This commit is contained in:
Niels 2010-05-22 16:07:49 +02:00
commit c29d3b66e4
10 changed files with 171 additions and 134 deletions

View File

@ -105,7 +105,7 @@ begin
result := SExt_ok; result := SExt_ok;
except except
on e : exception do on e : exception do
//formWritelnEx(format('Error in Simba extension (%s): %s',[Self.GetName,e.message])); psWriteLn(format('Error in Simba extension (%s): %s',[Self.GetName,e.message]));
end; end;
end; end;
@ -149,22 +149,22 @@ begin
end; end;
{$DEFINE MML_EXPORT_THREADSAFE} {$DEFINE MML_EXPORT_THREADSAFE}
{$I Wrappers/other.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/other.inc}
{$I Wrappers/settings.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/settings.inc}
{$I Wrappers/bitmap.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/bitmap.inc}
{$I Wrappers/window.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/window.inc}
{$I Wrappers/tpa.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/tpa.inc}
{$I Wrappers/strings.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/strings.inc}
{$I Wrappers/colour.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/colour.inc}
{$I Wrappers/colourconv.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/colourconv.inc}
{$I Wrappers/math.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/math.inc}
{$I Wrappers/mouse.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/mouse.inc}
{$I Wrappers/file.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/file.inc}
{$I Wrappers/keyboard.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/keyboard.inc}
{$I Wrappers/dtm.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/dtm.inc}
{$I Wrappers/ocr.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/ocr.inc}
{$I Wrappers/internets.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/internets.inc}
{$I Wrappers/extensions.inc} {$I ../../Units/MMLAddon/PSInc/Wrappers/extensions.inc}
procedure TSimbaPSExtension.RegisterMyMethods(x: TPSScript); procedure TSimbaPSExtension.RegisterMyMethods(x: TPSScript);
@ -196,11 +196,13 @@ begin
{$i ../../Units/MMLAddon/PSInc/psexportedmethods.inc} {$i ../../Units/MMLAddon/PSInc/psexportedmethods.inc}
AddFunction(@ext_SDTMToMDTM,'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;');
AddFunction(@ext_GetPage,'function GetPage(const url : string) : string'); AddFunction(@ext_GetPage,'function GetPage(const url : string) : string');
AddFunction(@ext_DecompressBZip2,'function DecompressBZip2(const input: string;out output : string; const BlockSize: Cardinal): boolean;'); AddFunction(@ext_DecompressBZip2,'function DecompressBZip2(const input: string;out output : string; const BlockSize: Cardinal): boolean;');
AddFunction(@ext_UnTar,'function UnTar(const Input : string; out Content : TStringArray) : boolean;'); AddFunction(@ext_UnTar,'function UnTar(const Input : string; out Content : TStringArray) : boolean;');
AddFunction(@ext_UnTarEx,'function UnTarEx(const Input : string;const outputdir : string; overwrite : boolean): boolean;'); AddFunction(@ext_UnTarEx,'function UnTarEx(const Input : string;const outputdir : string; overwrite : boolean): boolean;');
AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;'); AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;');
AddFunction(@ext_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;');
AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox'); AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox');
AddRegisteredVariable('Simba','TForm'); AddRegisteredVariable('Simba','TForm');
AddRegisteredVariable('Simba_MainMenu','TMainMenu'); AddRegisteredVariable('Simba_MainMenu','TMainMenu');

View File

@ -1299,7 +1299,7 @@ begin
if ConsoleVisible then if ConsoleVisible then
SetSetting('LastConfig/Console/Visible','True') SetSetting('LastConfig/Console/Visible','True')
else else
SetSetting('LastConfig/Console/Visible','false'); SetSetting('LastConfig/Console/Visible','False');
{$endif} {$endif}
SetSetting('Extensions/ExtensionCount',inttostr(ExtManager.Extensions.Count)); SetSetting('Extensions/ExtensionCount',inttostr(ExtManager.Extensions.Count));
for i := 0 to ExtManager.Extensions.Count-1 do for i := 0 to ExtManager.Extensions.Count-1 do
@ -2135,7 +2135,7 @@ begin
FillThread.NormalProc:= @CCFillCore; FillThread.NormalProc:= @CCFillCore;
UpdateTimer.OnTimer:= @UpdateTimerCheck; UpdateTimer.OnTimer:= @UpdateTimerCheck;
Application.CreateForm(TSimbaUpdateForm, SimbaUpdateForm); Application.CreateForm(TSimbaUpdateForm, SimbaUpdateForm);
if FileExists(SimbaSettingsFile) then if FileExistsUTF8(SimbaSettingsFile) then
begin begin
Application.CreateForm(TSettingsForm,SettingsForm); Application.CreateForm(TSettingsForm,SettingsForm);
Self.LoadFormSettings; Self.LoadFormSettings;

View File

@ -112,3 +112,13 @@ function ext_MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Butto
begin begin
result := MessageDlg(acaption,amsg,dlgtype,buttons,helpctx); result := MessageDlg(acaption,amsg,dlgtype,buttons,helpctx);
end; end;
function ext_SDTMToMDTM(Const DTM: TSDTM): TMDTM;
begin
result := SDTMToMDTM(DTM);
end;
function ext_InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
begin
result := InputQuery(acaption,aprompt,value);
end;

View File

@ -43,11 +43,11 @@ AddFunction(@ps_FindDTMsRotatedAlternating, 'function FindDTMsRotatedAlternating
AddFunction(@ps_addDTM, 'function AddMDTM(const d: TMDTM): Integer;'); AddFunction(@ps_addDTM, 'function AddMDTM(const d: TMDTM): Integer;');
AddFunction(@ps_addDTM, 'function AddDTM(const d: TMDTM): Integer;'); AddFunction(@ps_addDTM, 'function AddDTM(const d: TMDTM): Integer;');
AddFunction(@ps_addTSDTM, 'function AddSDTM(const d: TSDTM): Integer;'); AddFunction(@ps_addTSDTM, 'function AddSDTM(const d: TSDTM): Integer;');
AddFunction(@ps_PrintDTM, 'procedure PrintDTM(const DTM : TMDTM);');
AddFunction(@ps_GetDTM ,'function GetDTM(index: Integer) : TMDTM'); AddFunction(@ps_GetDTM ,'function GetDTM(index: Integer) : TMDTM');
{$ENDIF}
AddFunction(@ps_MDTMToSDTM, 'function MDTMToSDTM(Const DTM: TMDTM): TSDTM;');
AddFunction(@ps_SDTMToMDTM, 'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;'); AddFunction(@ps_SDTMToMDTM, 'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;');
{$ENDIF}
AddFunction(@ps_PrintDTM, 'procedure PrintDTM(const DTM : TMDTM);');
AddFunction(@ps_MDTMToSDTM, 'function MDTMToSDTM(Const DTM: TMDTM): TSDTM;');
AddFunction(@ps_CreateDTMPoint,'function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;'); AddFunction(@ps_CreateDTMPoint,'function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;');
{maths} {maths}
@ -107,8 +107,8 @@ AddFunction(@ps_IsTargetValid, 'function IsTargetValid: boolean;');
{files} {files}
SetCurrSection('Files'); SetCurrSection('Files');
AddFunction(@ps_CreateFile, 'function CreateFile(const Path: string): Integer;');
{$IFNDEF MML_EXPORT_THREADSAFE} {$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_CreateFile, 'function CreateFile(const Path: string): Integer;');
AddFunction(@ps_OpenFile, 'function OpenFile(const Path: string; Shared: Boolean): Integer;'); AddFunction(@ps_OpenFile, 'function OpenFile(const Path: string; Shared: Boolean): Integer;');
AddFunction(@ps_RewriteFile, 'function RewriteFile(const Path: string; Shared: Boolean): Integer;'); AddFunction(@ps_RewriteFile, 'function RewriteFile(const Path: string; Shared: Boolean): Integer;');
AddFunction(@ps_CloseFile, 'procedure CloseFile(FileNum: Integer);'); AddFunction(@ps_CloseFile, 'procedure CloseFile(FileNum: Integer);');
@ -198,10 +198,11 @@ AddFunction(@ps_ExecRegExpr,'function ExecRegExpr( const RegExpr, InputStr : Str
AddFunction(@ps_SplitRegExpr,'procedure SplitRegExpr( const RegExpr, InputStr : String; Pieces : TStrings);'); AddFunction(@ps_SplitRegExpr,'procedure SplitRegExpr( const RegExpr, InputStr : String; Pieces : TStrings);');
addfunction(@ps_ReplaceRegExpr,'function ReplaceRegExpr( const RegExpr, InputStr, ReplaceStr : String; UseSubstitution : boolean) : String;'); addfunction(@ps_ReplaceRegExpr,'function ReplaceRegExpr( const RegExpr, InputStr, ReplaceStr : String; UseSubstitution : boolean) : String;');
{$IFNDEF MML_EXPORT_THREADSAFE}
{web} {web}
SetCurrSection('Web'); SetCurrSection('Web');
AddFunction(@ps_OpenWebPage,'procedure OpenWebPage(const url : string);'); AddFunction(@ps_OpenWebPage,'procedure OpenWebPage(const url : string);');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_GetPage,'function GetPage(const url : string): string;'); AddFunction(@ps_GetPage,'function GetPage(const url : string): string;');
AddFunction(@ps_InitializeHTTPClient,'function InitializeHTTPClient(HandleCookies: Boolean): Integer;'); AddFunction(@ps_InitializeHTTPClient,'function InitializeHTTPClient(HandleCookies: Boolean): Integer;');
AddFunction(@ps_InitializeHTTPClient,'function InitializeHTTPClientWrap(HandleCookies: Boolean): Integer;'); AddFunction(@ps_InitializeHTTPClient,'function InitializeHTTPClientWrap(HandleCookies: Boolean): Integer;');

View File

@ -104,6 +104,8 @@ begin
RegisterMethod('procedure free;'); RegisterMethod('procedure free;');
RegisterProperty('Name','String',iptrw); RegisterProperty('Name','String',iptrw);
RegisterMethod('function ToString : string'); RegisterMethod('function ToString : string');
RegisterMethod('function LoadFromString(const s : string) : boolean;');
RegisterMethod('procedure Normalize;');
RegisterMethod('function Valid:boolean'); RegisterMethod('function Valid:boolean');
RegisterMethod('procedure DeletePoint( Point : integer);'); RegisterMethod('procedure DeletePoint( Point : integer);');
RegisterMethod('procedure SwapPoint(p1,p2 : integer);'); RegisterMethod('procedure SwapPoint(p1,p2 : integer);');

View File

@ -158,6 +158,8 @@ begin
RegisterConstructor(@TMDTM.Create,'Create'); RegisterConstructor(@TMDTM.Create,'Create');
RegisterMethod(@TMDTM.Free,'Free'); RegisterMethod(@TMDTM.Free,'Free');
RegisterMethod(@TMDTM.ToString,'ToString'); RegisterMethod(@TMDTM.ToString,'ToString');
RegisterMethod(@TMDTM.LoadFromString,'LoadFromString');
RegisterMethod(@TMDTM.Normalize,'Normalize');
RegisterMethod(@TMDTM.Valid,'Valid'); RegisterMethod(@TMDTM.Valid,'Valid');
RegisterMethod(@TMDTM.DeletePoint,'DeletePoint'); RegisterMethod(@TMDTM.DeletePoint,'DeletePoint');
RegisterMethod(@TMDTM.SwapPoint,'SwapPoint'); RegisterMethod(@TMDTM.SwapPoint,'SwapPoint');

View File

@ -42,6 +42,8 @@ It binds all the components together.
type type
TClient = class(TObject) TClient = class(TObject)
private
FOwnIOManager : boolean;
public public
IOManager: TIOManager; IOManager: TIOManager;
MFiles: TMFiles; MFiles: TMFiles;
@ -51,7 +53,7 @@ type
MOCR: TMOCR; MOCR: TMOCR;
WritelnProc : TWritelnProc; WritelnProc : TWritelnProc;
procedure WriteLn(s : string); procedure WriteLn(s : string);
constructor Create(plugin_dir: string); constructor Create(const plugin_dir: string = ''; const UseIOManager : TIOManager = nil);
destructor Destroy; override; destructor Destroy; override;
end; end;
@ -68,11 +70,15 @@ begin
end; end;
// Possibly pass arguments to a default window. // Possibly pass arguments to a default window.
constructor TClient.Create(plugin_dir: string); constructor TClient.Create(const plugin_dir: string = ''; const UseIOManager : TIOManager = nil);
begin begin
inherited Create; inherited Create;
WritelnProc:= nil; WritelnProc:= nil;
IOManager:= TIOManager.Create(plugin_dir); if UseIOManager = nil then
IOManager := TIOManager.Create(plugin_dir)
else
IOManager := UseIOManager;
FOwnIOManager := (UseIOManager = nil);
MFiles := TMFiles.Create(self); MFiles := TMFiles.Create(self);
MFinder := TMFinder.Create(Self); MFinder := TMFinder.Create(Self);
MBitmaps := TMBitmaps.Create(self); MBitmaps := TMBitmaps.Create(self);
@ -82,14 +88,16 @@ end;
destructor TClient.Destroy; destructor TClient.Destroy;
begin begin
IOManager.SetState(True); if FOwnIOManager then
IOManager.SetState(True);
MOCR.Free; MOCR.Free;
MDTMs.Free; MDTMs.Free;
MBitmaps.Free; MBitmaps.Free;
MFinder.Free; MFinder.Free;
MFiles.Free; MFiles.Free;
IOManager.Free; if FOwnIOManager then
IOManager.Free;
inherited; inherited;
end; end;

View File

@ -44,6 +44,8 @@ type
Name : string; Name : string;
Index : integer; Index : integer;
function ToString : string; function ToString : string;
function LoadFromString(const s : string) : boolean;
procedure Normalize;
function Valid : boolean; function Valid : boolean;
procedure DeletePoint( Point : integer); procedure DeletePoint( Point : integer);
procedure SwapPoint(p1,p2 : integer); procedure SwapPoint(p1,p2 : integer);
@ -146,91 +148,11 @@ end;
function TMDTMS.StringToDTM(const S: String): Integer; function TMDTMS.StringToDTM(const S: String): Integer;
var var
b: PBufferByteArray; aDTM : TMDTM;
MDTM : TMDTM;
Source : String;
DestLen : longword;
i,ii,c : integer;
DPoints : PMDTMPoint;
Ptr : Pointer;
function ReadInteger : integer;
begin begin
Result := PInteger(ptr)^; aDTM := TMDTM.Create;
inc(ptr,sizeof(integer)); aDTM.LoadFromString(s);
end; Result := AddDTM(aDTM);
function ReadBoolean : boolean;
begin
result := PBoolean(ptr)^;
inc(ptr,sizeof(boolean));
end;
begin
MDTM := TMDTM.Create;
Result := AddDTM(MDTM);
ii := Length(S);
if (ii = 0) then
exit;
if S[1] = 'm' then
begin
if ii < 9 then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
Source := Base64DecodeStr(copy(s,2,ii-1));
i:= PLongint(@source[1])^; //The 4 four bytes should contain the dest len!
if i < 1 then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
DestLen := BufferLen;
ptr := @Source[1 + sizeof(longint)];
if uncompress(BufferString,DestLen,ptr,length(source)-sizeof(integer)) = Z_OK then
begin
ptr := BufferString;
MDTM.Count:= ReadInteger;
ii := MDTM.Count;
if (MDTM.Count * TMDTMPointSize) <> (Destlen - SizeOf(integer)) then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
DPoints := MDTM.PPoints;
for i := 0 to ii-1 do
DPoints[i].x := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].y := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].c := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].t := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].asz := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].bp := ReadBoolean;
end;
end else
begin
if (ii mod 2 <> 0) then
exit;
ii := ii div 2;
SetLength(Source,ii);
for i := 1 to ii do
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
DestLen := BufferLen;
if uncompress(Bufferstring,Destlen,pchar(Source), ii) = Z_OK then
begin;
if (Destlen mod 36) > 0 then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
DestLen := DestLen div 36;
MDTM.Count:= DestLen;
DPoints := MDTM.PPoints;
b := PBufferByteArray(BufferString);
for i := 0 to DestLen - 1 do
begin;
c := i * 36;
DPoints[i].x := PInteger(@b^[c+1])^;
DPoints[i].y := PInteger(@b^[c+5])^;
DPoints[i].asz := PInteger(@b^[c+12])^;
// DPoints.ash[i] := PInteger(@b^[c+16])^;
DPoints[i].c := PInteger(@b^[c+20])^;
DPoints[i].t := PInteger(@b^[c+24])^;
DPoints[i].bp := False;
end;
end;
end;
end; end;
@ -264,7 +186,7 @@ begin
end; end;
DTMList[Result] := d; DTMList[Result] := d;
DTMList[Result].Index:= Result; DTMList[Result].Index:= Result;
NormalizeDTM(DTMList[result]); DTMList[result].Normalize;
end; end;
{/\ {/\
@ -363,12 +285,118 @@ begin
Freemem(start,len); Freemem(start,len);
end; end;
function TMDTM.LoadFromString(const s: string): boolean;
var
MDTM : TMDTM;
Source : String;
DestLen : longword;
i,ii,c : integer;
DPoints : PMDTMPoint;
Ptr : Pointer;
function ReadInteger : integer;
begin
Result := PInteger(ptr)^;
inc(ptr,sizeof(integer));
end;
function ReadBoolean : boolean;
begin
result := PBoolean(ptr)^;
inc(ptr,sizeof(boolean));
end;
begin
Result := false;
ii := Length(S);
if (ii = 0) then
exit;
if S[1] = 'm' then
begin
if ii < 9 then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
Source := Base64DecodeStr(copy(s,2,ii-1));
i:= PLongint(@source[1])^; //The 4 four bytes should contain the dest len!
if i < 1 then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
DestLen := BufferLen;
ptr := @Source[1 + sizeof(longint)];
if uncompress(BufferString,DestLen,ptr,length(source)-sizeof(integer)) = Z_OK then
begin
ptr := BufferString;
Self.Count:= ReadInteger;
ii := Self.Count;
if (Self.Count * TMDTMPointSize) <> (Destlen - SizeOf(integer)) then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
DPoints := Self.PPoints;
for i := 0 to ii-1 do
DPoints[i].x := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].y := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].c := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].t := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].asz := ReadInteger;
for i := 0 to ii-1 do
DPoints[i].bp := ReadBoolean;
Result := true;
end;
end else
begin
if (ii mod 2 <> 0) then
exit;
ii := ii div 2;
SetLength(Source,ii);
for i := 1 to ii do
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
DestLen := BufferLen;
if uncompress(Bufferstring,Destlen,pchar(Source), ii) = Z_OK then
begin;
if (Destlen mod 36) > 0 then
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
DestLen := DestLen div 36;
Self.Count:= DestLen;
DPoints := Self.PPoints;
ptr := bufferstring;
for i := 0 to DestLen - 1 do
begin;
DPoints[i].x :=PInteger(ptr + 1)^;
DPoints[i].y := PInteger(ptr + 5)^;
DPoints[i].asz := PInteger(ptr + 12)^;
// DPoints.ash[i] := PInteger(@b^[c+16])^;
DPoints[i].c := PInteger(ptr + 20)^;
DPoints[i].t := PInteger(ptr + 24)^;
DPoints[i].bp := False;
inc(ptr,36);
end;
Result := true;
end;
end;
if result then
Normalize;
end;
procedure TMDTM.Normalize;
var
i:integer;
begin
if (self = nil) or (Self.count < 1) or ((Self.Points[0].x = 0) and (Self.Points[0].y = 0)) then //Already normalized
exit;
for i := 1 to Self.Count - 1 do
begin
Self.Points[i].x := Self.Points[i].x - Self.Points[0].x;
Self.Points[i].y := Self.Points[i].y - Self.Points[0].y;
end;
Self.Points[0].x := 0;
Self.Points[0].y := 0;
end;
function TMDTM.Valid: boolean; function TMDTM.Valid: boolean;
begin begin
result := false; result := false;
if Count < 1 then if Count < 1 then
exit; exit;
NormalizeDTM(self); Normalize;
result := true; result := true;
end; end;

View File

@ -41,7 +41,6 @@ function ValidMainPointBox(var dtm: TMDTM; const x1, y1, x2, y2: Integer): TBox;
function ValidMainPointBox(const TPA: TPointArray; const x1, y1, x2, y2: Integer): TBox; function ValidMainPointBox(const TPA: TPointArray; const x1, y1, x2, y2: Integer): TBox;
function ValidMainPointBoxRotated(var dtm: TMDTM; const x1, y1, x2, y2: Integer;const function ValidMainPointBoxRotated(var dtm: TMDTM; const x1, y1, x2, y2: Integer;const
sAngle, eAngle, aStep: Extended): TBox; sAngle, eAngle, aStep: Extended): TBox;
procedure NormalizeDTM(var dtm: TMDTM);
{function RotateDTM(const dtm: TMDTM; angle: extended) : TMDTM; {function RotateDTM(const dtm: TMDTM; angle: extended) : TMDTM;
function copydtm(const dtm: TMDTM): TMDTM; } function copydtm(const dtm: TMDTM): TMDTM; }
@ -142,21 +141,6 @@ begin
result.Points[i].bp := false; result.Points[i].bp := false;
end; end;
procedure NormalizeDTM(var dtm: TMDTM);
var
i:integer;
begin
if (dtm = nil) or (dtm.count < 1) or ((dtm.Points[0].x = 0) and (dtm.Points[0].y = 0)) then //Already normalized
exit;
for i := 1 to dtm.Count - 1 do
begin
dtm.Points[i].x := dtm.Points[i].x - dtm.Points[0].x;
dtm.Points[i].y := dtm.Points[i].y - dtm.Points[0].y;
end;
dtm.Points[0].x := 0;
dtm.Points[0].y := 0;
end;
function ValidMainPointBox(var dtm: TMDTM; const x1, y1, x2, y2: Integer): TBox; function ValidMainPointBox(var dtm: TMDTM; const x1, y1, x2, y2: Integer): TBox;
var var
@ -164,7 +148,7 @@ var
b: TBox; b: TBox;
begin begin
NormalizeDTM(dtm); dtm.Normalize;
FillChar(b, SizeOf(TBox), 0); //Sets all the members to 0 FillChar(b, SizeOf(TBox), 0); //Sets all the members to 0
b.x1 := MaxInt; b.x1 := MaxInt;
@ -203,7 +187,7 @@ var
d:extended; d:extended;
begin begin
NormalizeDTM(dtm); dtm.normalize;
{ Delete the ASZ { Delete the ASZ
for i := 0 to high(dtm.c) do for i := 0 to high(dtm.c) do

View File

@ -2178,7 +2178,7 @@ begin
if not dtm.Valid then if not dtm.Valid then
raise Exception.CreateFmt('FindDTMs: DTM[%s] is not consistent.', [DTM.name]); raise Exception.CreateFmt('FindDTMs: DTM[%s] is not consistent.', [DTM.name]);
NormalizeDTM(DTM); dtm.Normalize;;
Len := DTM.Count; Len := DTM.Count;
DPoints:= DTM.PPoints; DPoints:= DTM.PPoints;